Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The Solution #373
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
base: master
Are you sure you want to change the base?
Uh oh!
There was an error while loading. Please reload this page.
The Solution #373
Changes from 1 commit
ede48a020a1d35File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.
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.
This checks for
..anywhere in the URL, but the requirement states 'If the pathname contains../'. The current implementation would block filenames like..hiddenorindex..htmleven though they don't contain the path traversal sequence../. Consider checking for../specifically instead.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.
The condition
|| decodedUrl === '/app.js'is not part of the requirements. The task only requires blocking paths containing../. Consider removing this extra check.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.
The condition
!decodedUrl.startsWith('/file')returns badRequest (400), but requirement #3 specifies that paths NOT starting with/file/should return a hint message (200). For example,/anythingshould return hint, not 400. This check should only return badRequest for..(path traversal), not for missing/file/prefix.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.
The hint logic at line 28-30 is unreachable for paths like
/anythingbecause line 22 catches them first. According to requirements,/anythingshould return hint (200), not badRequest (400). ThestartsWith('/file')check needs to be moved after the..check and return hint instead of badRequest.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.
When the URL is
/file/,urlArr.slice(1)produces an empty array, resulting infilename = 'public/'. The code then tries to read a directory instead ofpublic/index.html. According to the requirements,/file/should returnpublic/index.html.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.
This line combines two separate conditions that should be handled independently.
includes('..')correctly returns 400 (checklist item #5), but!decodedUrl.startsWith('/file')should return hint (200) per checklist item #3, not badRequest (400). Consider splitting: first check for..returning 400, then check if path starts with/filefor hint.Uh oh!
There was an error while loading. Please reload this page.