hotfix: use strings.TrimPrefix() for relative paths#145
Merged
niemeyer merged 4 commits intocanonical:mainfrom Jul 4, 2024
Merged
hotfix: use strings.TrimPrefix() for relative paths#145niemeyer merged 4 commits intocanonical:mainfrom
niemeyer merged 4 commits intocanonical:mainfrom
Conversation
Use ``strings.TrimPrefix()`` for relative paths instead of ``strings.TrimLeft()``, since ``TrimLeft`` takes in a cutset instead of a prefix sub-string. In this particular case, if the ``--root`` (output) directory is ``/tmp/foo`` and we are determining the relative path for ``/tmp/foo/tmp-foo``, the relative path would result in ``/-foo`` since ``/tmp/foo/tmp`` would be matched by the ``/tmp/foo/`` cutset. This results in a flawed map of ``knownPaths`` inside slicer.go, which is only checked by the mutation script functions such as ``content.list()``. This commit fixes said bug.
letFunny
suggested changes
Jul 3, 2024
Collaborator
letFunny
left a comment
There was a problem hiding this comment.
Thank you Rafid for doing your due diligence and for submitting the bugfix so quickly!
cjdcordeiro
approved these changes
Jul 3, 2024
Collaborator
cjdcordeiro
left a comment
There was a problem hiding this comment.
Thanks for the fix @rebornplusplus .
niemeyer
approved these changes
Jul 4, 2024
Contributor
niemeyer
left a comment
There was a problem hiding this comment.
Good catch, thanks Rafid.
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.
Use
strings.TrimPrefix()for relative paths instead ofstrings.TrimLeft(), sinceTrimLefttakes in a cutset instead of a prefix sub-string.In this particular case, if the
--root(output) directory is/tmp/fooand we are determining the relative path for/tmp/foo/tmp-foo, the relative path would result in/-foosince/tmp/foo/tmpwould be matched by the/tmp/foo/cutset.This results in a flawed map of
knownPathsinside slicer.go, which is only checked by the mutation script functions such ascontent.list().This commit fixes said bug.