refactor(filesystem): clean up isValidPath() logic and update docs - #57325
Open
joshtrichards wants to merge 2 commits into
Open
refactor(filesystem): clean up isValidPath() logic and update docs#57325joshtrichards wants to merge 2 commits into
isValidPath() logic and update docs#57325joshtrichards wants to merge 2 commits into
Conversation
…y docs Signed-off-by: Josh <josh.t.richards@gmail.com>
Signed-off-by: Josh <josh.t.richards@gmail.com>
joshtrichards
marked this pull request as ready for review
January 4, 2026 01:56
joshtrichards
requested review from
Altahrim,
leftybournes,
salmart-dev and
yemkareems
and removed request for
a team
January 4, 2026 01:56
Altahrim
approved these changes
Jan 5, 2026
susnux
reviewed
Jan 6, 2026
Comment on lines
+395
to
+403
| * This method is the primary defense against directory traversal and | ||
| * path manipulation attacks. It ALWAYS normalizes the input (see {@see normalizePath}), | ||
| * converting slash and unicode variants to a canonical absolute path. | ||
| * | ||
| * After normalization, any path containing '/..' segments (traversal attempts) is rejected. | ||
| * Normalized paths like '//foo//bar' are allowed and become '/foo/bar'. | ||
| * | ||
| * @param string $path Untrusted or user-supplied path to check. | ||
| * @return bool True if the path is safe, false otherwise. |
Contributor
There was a problem hiding this comment.
The doc string is longer than the implementation of the the function, it literally describes the implementation.
IMHO this is not a good thing because docs are not always kept up to date and will differ from implementation and then it just confuses at some point.
Better to just state the intent of the method and make the code itself self explaining.
Merged
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
strrchrwithstr_ends_withNo functional change in logic: the production code path is just simpler and optimized.
TODO
Checklist
3. to review, feature component)stable32)