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

Fix double-escaped paths on Windows #9814

Merged
merged 1 commit into from
Nov 12, 2019

Conversation

RReverser
Copy link
Collaborator

@RReverser RReverser commented Nov 9, 2019

On Windows, paths are using \, which is escaped to \\ by llvm-dwarfdump in its output.

We need to unescape them before passing to source map encoder, as otherwise we end up with invalid paths and URLs that can't be resolved.

This wasn't caught before, because assertPathsIdentical was performing its own unescaping before comparing paths, which is not what happens in real source map consumers.

Fixes #9811.

@@ -808,8 +808,8 @@ def assertNotExists(self, filename, msg=None):

# Tests that the given two paths are identical, modulo path delimiters. E.g. "C:/foo" is equal to "C:\foo".
def assertPathsIdentical(self, path1, path2):
path1 = path1.replace('\\', '/').replace('//', '/')
path2 = path2.replace('\\', '/').replace('//', '/')
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not totally sure about this.. but if not tests fail then I guess its fine.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

As I said in the description, this is what was hiding the problem in the first place - assertPathsIdentical shouldn't fix double-slashes itself, as real consumers also wouldn't.

On Windows, paths are using \, which is escaped to \\ by llvm-dwarfdump in its output.

We need to unescape them before passing to source map encoder, as otherwise we end up with invalid paths and URLs that can't be resolved.

This wasn't caught before, because assertPathsIdentical was performing its own unescaping before comparing paths, which is not what happens in real source map consumers.

Fixes emscripten-core#9811.
@kripken
Copy link
Member

kripken commented Nov 11, 2019

lgtm too, thanks @RReverser!

Is this ready to merge, or was there something more to look into here?

@RReverser
Copy link
Collaborator Author

Yes, this is ready to merge - the other issue is completely separate.

@kripken
Copy link
Member

kripken commented Nov 12, 2019

Thanks, merging!

I'd like to look at the other issue that you noticed, but I don't remember what it was, was that filed?

@kripken kripken merged commit 1dd4baa into emscripten-core:incoming Nov 12, 2019
@RReverser
Copy link
Collaborator Author

@kripken I haven't before due to lack of time, but submitted and described to best of my ability now in #9837.

belraquib pushed a commit to belraquib/emscripten that referenced this pull request Dec 23, 2020
On Windows, paths are using \, which is escaped to \\ by llvm-dwarfdump in its output.

We need to unescape them before passing to source map encoder, as otherwise we end up with invalid paths and URLs that can't be resolved.

This wasn't caught before, because assertPathsIdentical was performing its own unescaping before comparing paths, which is not what happens in real source map consumers.

Fixes emscripten-core#9811.
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.

Emscripten produces invalid file paths in source maps on Windows
3 participants