Skip to content

Commit

Permalink
[Import Maps] Disallow backtracking in prefix matching
Browse files Browse the repository at this point in the history
Reflecting
WICG/import-maps#229

Bug: 848607, WICG/import-maps#207
Change-Id: Id056b3fd27489ecdfe45456220fd1d8c01dc8d3f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2570012
Commit-Queue: Hiroshige Hayashizaki <hiroshige@chromium.org>
Reviewed-by: Kouhei Ueno <kouhei@chromium.org>
Reviewed-by: Domenic Denicola <domenic@chromium.org>
Cr-Commit-Position: refs/heads/master@{#833945}
GitOrigin-RevId: 916cc2354cae22a6e8280f2a2b7ac66b30b99e67
  • Loading branch information
hiroshige-g authored and Copybara-Service committed Dec 5, 2020
1 parent e8730d3 commit a802f52
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 176 deletions.
12 changes: 11 additions & 1 deletion blink/renderer/core/script/import_map.cc
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,17 @@ KURL ImportMap::ResolveImportsMatchInternal(const String& key,
return NullURL();
}

// <spec step="1.2.8">Return url.</spec>
// <spec step="1.2.8">If the serialization of url does not start with the
// serialization of resolutionResult, then throw a TypeError indicating that
// resolution of normalizedSpecifier was blocked due to it backtracking above
// its prefix specifierKey.</spec>
if (!url.GetString().StartsWith(matched->value.GetString())) {
*debug_message = "Import Map: \"" + key + "\" matches with \"" +
matched->key + "\" but is blocked due to backtracking";
return NullURL();
}

// <spec step="1.2.9">Return url.</spec>
*debug_message = "Import Map: \"" + key + "\" matches with \"" +
matched->key + "\" and is mapped to " + url.ElidedString();
return url;
Expand Down

This file was deleted.

0 comments on commit a802f52

Please sign in to comment.