-
Notifications
You must be signed in to change notification settings - Fork 55
hotfix: use strings.TrimPrefix() for relative paths #145
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
hotfix: use strings.TrimPrefix() for relative paths #145
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
left a comment
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.
Thank you Rafid for doing your due diligence and for submitting the bugfix so quickly!
letFunny
left a comment
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.
Thanks, LGTM!
cjdcordeiro
left a comment
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.
Thanks for the fix @rebornplusplus .
niemeyer
left a comment
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.
Good catch, thanks Rafid.
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.