Skip to content

Commit

Permalink
Fix double-escaped paths on Windows (#9814)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
RReverser authored and kripken committed Nov 12, 2019
1 parent 6b86c0b commit 1dd4baa
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions tests/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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('//', '/')
path1 = path1.replace('\\', '/')
path2 = path2.replace('\\', '/')
return self.assertIdentical(path1, path2)

# Tests that the given two multiline text content are identical, modulo line
Expand Down
2 changes: 1 addition & 1 deletion tools/wasm-sourcemap.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def resolve(self, name):
if name in self.cache:
return self.cache[name]

result = name
result = name.replace('\\', '/').replace('//', '/')
for p in self.prefixes:
if name.startswith(p['prefix']):
if p['replacement'] is None:
Expand Down

0 comments on commit 1dd4baa

Please sign in to comment.