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

fixed regexp not properly escape windows backslash in path #17690

Closed
wants to merge 2 commits into from
Closed

fixed regexp not properly escape windows backslash in path #17690

wants to merge 2 commits into from

Conversation

brainfoolong
Copy link

Suddenly, my CLI stopped working when provided a file path on windows in npx playwright test c:\foo\bar\123. I tracked it down, that the cli runner forces a path to become a regex, if a string is given. But, for whatever reason (I don't see any relevant change here since a long time), this stopped working. If a path contains a backslash (so on windows), the regex never match, because a backslash need to be double escaped. Especially when you have number as filename in your path, it get's weird. Example: c:\foo\bar\3rdparty will become c:\foo\bar\x03rdparty in the regex, without escaping.

This change fix this behaviour.
Also this works when providing already escaped backslashes in path.

Here is the regex test for it: https://regex101.com/r/W5QO7Q/2

I don't see why this has ever worked before, but maybe a TS compiler change or a NodeJs change in a recent version (i am on 16.17.0 now) caused this regex to no longer work.

Suddenly, my CLI stopped working when provided a file path on windows in `npx playwright test c:\foo\bar\123`.
I tracked it down, that the cli runner forces a path to become a regex, if a string is given.
But, for whatever reason (I don't see any relevant change here since a long time), this stopped working.
If a path contains a backslash (so on windows), the regex never match, because a backslash need to be double escaped.
Especially when you have number as filename in your path, it get's weird. Example: `c:\foo\bar\3rdparty` will become `c:\foo\bar\x03rdparty` in the regex, without escaping.

This change fix this behaviour.
Also this works when providing already escaped backslashes in path.

Here is the regex test for it: https://regex101.com/r/W5QO7Q/2

I don't see why this has ever worked before, but maybe a TS compiler change or a NodeJs change in a recent version (i am on 16.17.0 now) caused this regex to no longer work.
@pavelfeldman
Copy link
Member

Our file paths are regex by the documentation, so sadly this requires double-escaping on windows.

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.

2 participants