Created
September 1, 2011 17:46
-
-
Save shiawuen/1186754 to your computer and use it in GitHub Desktop.
prevent access /etc/passwd
This file contains 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
var path = require('path') | |
var userPath = path.normalize('/var/www/app/abc/../../../../../../../../../../etc/passwd') | |
if (userPath.indexOf(__dirname) == 0 ) { | |
// Valid path | |
} else { | |
// Invalid path | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment