Skip to content
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

chore: fix incomplete sanitization #6328

Merged
merged 1 commit into from
Sep 2, 2018
Merged

chore: fix incomplete sanitization #6328

merged 1 commit into from
Sep 2, 2018

Conversation

s0
Copy link
Contributor

@s0 s0 commented Aug 29, 2018

Summary

This PR fixes an alert that was found on LGTM: https://lgtm.com/projects/g/yarnpkg/yarn/alerts/?mode=tree&ruleFocus=1506222917439

yarn/src/util/filter.js

Lines 103 to 104 in 8cbbc6d

// the micromatch regex expects unix path separators
loc = loc.replace('\\', '/');

This replacement was incomplete, and would only replace the first backslash which is not what was intended.

Test plan

Output from node:

> 'fooo\\bar\\baz'.replace('\\', '/')
'fooo/bar\\baz'
> 'fooo\\bar\\baz'.replace(/\\/g, '/')
'fooo/bar/baz'

I'm not sure how to otherwise test this part of the code, or introduce a test case that proves that the previous version fails and the fix fixes it.

Copy link

@batebobo batebobo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@arcanis arcanis merged commit 047b10a into yarnpkg:master Sep 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants