Check files improve path normalization#382
Open
inqrphl wants to merge 2 commits into
Open
Conversation
path normalization function cleans up the paths, and is then used for depth calculation. for windows, convert forward slashes to backward slashes using filepath.FromSlash for all systems, replace groups of seperators into a single seperator. this prevents a////b////c from having higher depth than a/b/c
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.
normalized path is used for depth calculation. the depth is the count difference of filesystem separators
it is also used to check if an filesystem item is inside another filesystem item.
for windows, the paths could be specified using forward slashes like this: "C:/Windows". This meant that this block in normalizePath would run and append a backward slash making the path "C:/Windows" .
Discovered files would look like "C:/Windows/test.txt" and would not be considered as under "C:/Windows", breaking the check.
convert forward slashes to backward slashes using filepath.FromSlash before that block.
Replace groups of separators into a single separator. This prevents a////b////c from having higher depth than a/b/c .
Fixing this issue as well, it did not come from a bug report but found while looking through the code.