Commit 93a9bfed authored by Hiroshige Hayashizaki's avatar Hiroshige Hayashizaki Committed by Commit Bot

[Import Maps] Reject values not ending with "/" for keys ending with "/"

Bug: 990561
Change-Id: Id9eae41b435aca6ce97a2fa5317d63e5b0d52d86
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1734210Reviewed-by: default avatarDomenic Denicola <domenic@chromium.org>
Reviewed-by: default avatarKouhei Ueno <kouhei@chromium.org>
Commit-Queue: Hiroshige Hayashizaki <hiroshige@chromium.org>
Cr-Commit-Position: refs/heads/master@{#688453}
parent 52db8740
...@@ -117,8 +117,18 @@ KURL NormalizeValue(const String& key, ...@@ -117,8 +117,18 @@ KURL NormalizeValue(const String& key,
case ParsedSpecifier::Type::kURL: case ParsedSpecifier::Type::kURL:
// <spec step="3.3.4">If specifierKey ends with U+002F (/), and the // <spec step="3.3.4">If specifierKey ends with U+002F (/), and the
// serialization of addressURL does not end with U+002F (/), then:</spec> // serialization of addressURL does not end with U+002F (/), then:</spec>
// if (key.EndsWith("/") && !value.GetUrl().GetString().EndsWith("/")) {
// TODO(hiroshige): Implement this. // <spec step="3.3.4.1">Report a warning to the console that an invalid
// address was given for the specifier key specifierKey; since
// specifierKey ended in a slash, so must the address.</spec>
AddIgnoredValueMessage(
logger, key,
"Since specifierKey ended in a slash, so must the address: " +
value_string);
// <spec step="3.3.4.2">Continue.</spec>
return NullURL();
}
// <spec step="3.3.5">Append addressURL to // <spec step="3.3.5">Append addressURL to
// validNormalizedAddresses.</spec> // validNormalizedAddresses.</spec>
...@@ -241,7 +251,7 @@ ImportMap::SpecifierMap ImportMap::SortAndNormalizeSpecifierMap( ...@@ -241,7 +251,7 @@ ImportMap::SpecifierMap ImportMap::SortAndNormalizeSpecifierMap(
case JSONValue::ValueType::kTypeString: { case JSONValue::ValueType::kTypeString: {
// <spec step="2.3">If value is a string, then set // <spec step="2.3">If value is a string, then set
// normalized[normalizedSpecifierKey] to ≪value≫.</spec> // normalized[normalizedSpecifierKey] to «value».</spec>
String value_string; String value_string;
if (!imports->GetString(entry.first, &value_string)) { if (!imports->GetString(entry.first, &value_string)) {
AddIgnoredValueMessage(logger, entry.first, AddIgnoredValueMessage(logger, entry.first,
......
...@@ -10,9 +10,9 @@ FAIL Absolute URL addresses / should only accept absolute URL addresses with fet ...@@ -10,9 +10,9 @@ FAIL Absolute URL addresses / should only accept absolute URL addresses with fet
FAIL Absolute URL addresses / should only accept absolute URL addresses with fetch schemes inside arrays assert_equals: expected "{\"about\":[\"about:good\"],\"blob\":[\"blob:good\"],\"data\":[\"data:good\"],\"file\":[\"file:///good\"],\"filesystem\":[\"filesystem:good\"],\"ftp\":[\"ftp://good/\"],\"http\":[\"http://good/\"],\"https\":[\"https://good/\"],\"import\":[],\"javascript\":[],\"mailto\":[],\"wss\":[]}" but got "{\"about\":[\"about:good\"],\"blob\":[\"blob:good\"],\"data\":[\"data:good\"],\"file\":[\"file:///good\"],\"filesystem\":[],\"ftp\":[\"ftp://good/\"],\"http\":[\"http://good/\"],\"https\":[\"https://good/\"],\"import\":[\"import:bad\"],\"javascript\":[\"javascript:bad\"],\"mailto\":[\"mailto:bad\"],\"wss\":[\"wss://bad/\"]}" FAIL Absolute URL addresses / should only accept absolute URL addresses with fetch schemes inside arrays assert_equals: expected "{\"about\":[\"about:good\"],\"blob\":[\"blob:good\"],\"data\":[\"data:good\"],\"file\":[\"file:///good\"],\"filesystem\":[\"filesystem:good\"],\"ftp\":[\"ftp://good/\"],\"http\":[\"http://good/\"],\"https\":[\"https://good/\"],\"import\":[],\"javascript\":[],\"mailto\":[],\"wss\":[]}" but got "{\"about\":[\"about:good\"],\"blob\":[\"blob:good\"],\"data\":[\"data:good\"],\"file\":[\"file:///good\"],\"filesystem\":[],\"ftp\":[\"ftp://good/\"],\"http\":[\"http://good/\"],\"https\":[\"https://good/\"],\"import\":[\"import:bad\"],\"javascript\":[\"javascript:bad\"],\"mailto\":[\"mailto:bad\"],\"wss\":[\"wss://bad/\"]}"
FAIL Absolute URL addresses / should parse absolute URLs, ignoring unparseable ones assert_equals: expected "{\"invalidButParseable1\":[\"https://example.org/\"],\"invalidButParseable2\":[\"https://example.com///\"],\"noPercentDecoding\":[\"https://example.com/%41\"],\"percentDecoding\":[\"https://example.com/\"],\"prettyNormal\":[\"https://example.net/\"],\"unparseable1\":[],\"unparseable2\":[],\"unparseable3\":[]}" but got "{\"invalidButParseable1\":[\"https://example.org/\"],\"invalidButParseable2\":[\"https://example.com///\"],\"noPercentDecoding\":[\"https://example.com/A\"],\"percentDecoding\":[\"https://example.com/\"],\"prettyNormal\":[\"https://example.net/\"],\"unparseable1\":[\"https://ex%20ample.org/\"],\"unparseable2\":[],\"unparseable3\":[]}" FAIL Absolute URL addresses / should parse absolute URLs, ignoring unparseable ones assert_equals: expected "{\"invalidButParseable1\":[\"https://example.org/\"],\"invalidButParseable2\":[\"https://example.com///\"],\"noPercentDecoding\":[\"https://example.com/%41\"],\"percentDecoding\":[\"https://example.com/\"],\"prettyNormal\":[\"https://example.net/\"],\"unparseable1\":[],\"unparseable2\":[],\"unparseable3\":[]}" but got "{\"invalidButParseable1\":[\"https://example.org/\"],\"invalidButParseable2\":[\"https://example.com///\"],\"noPercentDecoding\":[\"https://example.com/A\"],\"percentDecoding\":[\"https://example.com/\"],\"prettyNormal\":[\"https://example.net/\"],\"unparseable1\":[\"https://ex%20ample.org/\"],\"unparseable2\":[],\"unparseable3\":[]}"
FAIL Absolute URL addresses / should parse absolute URLs, ignoring unparseable ones inside arrays assert_equals: expected "{\"invalidButParseable1\":[\"https://example.org/\"],\"invalidButParseable2\":[\"https://example.com///\"],\"noPercentDecoding\":[\"https://example.com/%41\"],\"percentDecoding\":[\"https://example.com/\"],\"prettyNormal\":[\"https://example.net/\"],\"unparseable1\":[],\"unparseable2\":[],\"unparseable3\":[]}" but got "{\"invalidButParseable1\":[\"https://example.org/\"],\"invalidButParseable2\":[\"https://example.com///\"],\"noPercentDecoding\":[\"https://example.com/A\"],\"percentDecoding\":[\"https://example.com/\"],\"prettyNormal\":[\"https://example.net/\"],\"unparseable1\":[\"https://ex%20ample.org/\"],\"unparseable2\":[],\"unparseable3\":[]}" FAIL Absolute URL addresses / should parse absolute URLs, ignoring unparseable ones inside arrays assert_equals: expected "{\"invalidButParseable1\":[\"https://example.org/\"],\"invalidButParseable2\":[\"https://example.com///\"],\"noPercentDecoding\":[\"https://example.com/%41\"],\"percentDecoding\":[\"https://example.com/\"],\"prettyNormal\":[\"https://example.net/\"],\"unparseable1\":[],\"unparseable2\":[],\"unparseable3\":[]}" but got "{\"invalidButParseable1\":[\"https://example.org/\"],\"invalidButParseable2\":[\"https://example.com///\"],\"noPercentDecoding\":[\"https://example.com/A\"],\"percentDecoding\":[\"https://example.com/\"],\"prettyNormal\":[\"https://example.net/\"],\"unparseable1\":[\"https://ex%20ample.org/\"],\"unparseable2\":[],\"unparseable3\":[]}"
FAIL Failing addresses: mismatched trailing slashes / should warn for the simple case assert_equals: expected "{\"std:trailer/\":[],\"trailer/\":[]}" but got "{\"trailer/\":[\"https://base.example/notrailer\"]}" FAIL Failing addresses: mismatched trailing slashes / should warn for the simple case assert_equals: expected "{\"std:trailer/\":[],\"trailer/\":[]}" but got "{\"trailer/\":[]}"
FAIL Failing addresses: mismatched trailing slashes / should warn for a mismatch alone in an array assert_equals: expected "{\"std:trailer/\":[],\"trailer/\":[]}" but got "{\"trailer/\":[\"https://base.example/notrailer\"]}" FAIL Failing addresses: mismatched trailing slashes / should warn for a mismatch alone in an array assert_equals: expected "{\"std:trailer/\":[],\"trailer/\":[]}" but got "{\"trailer/\":[]}"
FAIL Failing addresses: mismatched trailing slashes / should warn for a mismatch alongside non-mismatches in an array assert_equals: expected "{\"std:trailer/\":[\"https://base.example/bim-atrailer/\"],\"trailer/\":[\"https://base.example/atrailer/\"]}" but got "{\"trailer/\":[]}" FAIL Failing addresses: mismatched trailing slashes / should warn for a mismatch alongside non-mismatches in an array assert_equals: expected "{\"std:trailer/\":[\"https://base.example/bim-atrailer/\"],\"trailer/\":[\"https://base.example/atrailer/\"]}" but got "{\"trailer/\":[\"https://base.example/atrailer/\"]}"
PASS Other invalid addresses / should ignore unprefixed strings that are not absolute URLs PASS Other invalid addresses / should ignore unprefixed strings that are not absolute URLs
Harness: the test ran to completion. Harness: the test ran to completion.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment