-
Notifications
You must be signed in to change notification settings - Fork 208
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Additional PHP path sanitization #1296
base: master
Are you sure you want to change the base?
Additional PHP path sanitization #1296
Conversation
# Make sure we don't have any path shenanigans going on | ||
$path=str_replace(array("..","./"),"",$path); | ||
# we don't need trailing slashes, and leading slashes are going to be invalid paths | ||
$path=trim($path,"/"); | ||
$path=sanitize(trim($path,"/")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why would you sanitize this again after it was done four lines up?
@@ -120,7 +120,7 @@ function BuildFileList($returnjson=false,$path="."){ | |||
# Make sure we don't have any path shenanigans going on | |||
$path=str_replace(array("..","./"),"",$path); | |||
# we don't need trailing slashes, and leading slashes are going to be invalid paths | |||
$path=trim($path,"/"); | |||
$path=sanitize(trim($path,"/")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same question as above?
Code injection test cases |
The path is getting manipulated again after it’s sanitized. I wonder if it actually makes more sense to have the sanitization be the last thing that happens to the path instead of the first? |
The santitize function is to protect against user injected crap. It's not being touched by the user after the first sanitize() call, therefore any subsequent calls to it are simply wasted cycles. |
eb143e5 added PHP sanitization to one
$path=trim($path)
, but there were three others, so this PR adds the same logic to those