Last active
August 29, 2015 14:23
-
-
Save mykiimike/a162541761df6fd54f48 to your computer and use it in GitHub Desktop.
NodeJS Prevent Local File Inclusion and NULL byte attack
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String.prototype.safe = function() { | |
var s = this.toString().split("/"), r = []; | |
for(var a in s) { | |
if(s[a] != "..") | |
r.push(s[a]); | |
} | |
r = r.join("/"); | |
var i = r.indexOf("\0"); | |
if(i > 0) | |
r = r.substr(0, i); | |
return(r); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment