Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(72)

Unified Diff: url/url_util.cc

Issue 2159203002: Fix inconsistent values of anchor element IDL attributes compare to other vendors Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « url/url_canon_etc.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: url/url_util.cc
diff --git a/url/url_util.cc b/url/url_util.cc
index c1e997992d3569496b96e64014a79e692bc01bcf..81dfc51801cb9e3299e36688be8a8963f3419492 100644
--- a/url/url_util.cc
+++ b/url/url_util.cc
@@ -40,12 +40,23 @@ const SchemeWithType kReferrerURLSchemes[kNumReferrerURLSchemes] = {
{kHttpsScheme, SCHEME_WITH_PORT},
};
+const int kNumPathURLSchemes = 6;
+const SchemeWithType kPathURLSchemes[kNumPathURLSchemes] = {
+ {kAboutScheme, SCHEME_WITHOUT_PORT},
+ {kBlobScheme, SCHEME_WITHOUT_PORT},
+ {kContentScheme, SCHEME_WITHOUT_PORT},
+ {kContentIDScheme, SCHEME_WITHOUT_PORT},
+ {kDataScheme, SCHEME_WITHOUT_PORT},
+ {kJavaScriptScheme, SCHEME_WITHOUT_PORT},
+};
+
// Lists of the currently installed standard and referrer schemes. These lists
// are lazily initialized by InitStandardSchemes and InitReferrerSchemes and are
// leaked on shutdown to prevent any destructors from being called that will
// slow us down or cause problems.
std::vector<SchemeWithType>* standard_schemes = nullptr;
std::vector<SchemeWithType>* referrer_schemes = nullptr;
+std::vector<SchemeWithType>* path_schemes = nullptr;
// See the LockSchemeRegistries declaration in the header.
bool scheme_registries_locked = false;
@@ -84,6 +95,12 @@ void InitReferrerSchemes() {
InitSchemes(&referrer_schemes, kReferrerURLSchemes, kNumReferrerURLSchemes);
}
+// Ensures that the path_schemes list is initialized, does nothing if
+// it already has values.
+void InitPathSchemes() {
+ InitSchemes(&path_schemes, kPathURLSchemes, kNumPathURLSchemes);
+}
+
// Given a string and a range inside the string, compares it to the given
// lower-case |compare_to| buffer.
template<typename CHAR>
@@ -125,6 +142,11 @@ bool DoIsStandard(const CHAR* spec, const Component& scheme, SchemeType* type) {
return DoIsInSchemes(spec, scheme, type, *standard_schemes);
}
+template <typename CHAR>
+bool DoIsPath(const CHAR* spec, const Component& scheme, SchemeType* type) {
+ InitPathSchemes();
+ return DoIsInSchemes(spec, scheme, type, *path_schemes);
+}
template<typename CHAR>
bool DoFindAndCompareScheme(const CHAR* str,
@@ -217,11 +239,17 @@ bool DoCanonicalize(const CHAR* in_spec,
success = CanonicalizeMailtoURL(spec, spec_len, parsed_input, output,
output_parsed);
- } else {
+ } else if (DoIsPath(spec, scheme, &unused_scheme_type)) {
// "Weird" URLs like data: and javascript:.
ParsePathURL(spec, spec_len, trim_path_end, &parsed_input);
success = CanonicalizePathURL(spec, spec_len, parsed_input, output,
output_parsed);
+
+ } else {
+ // All other urls.
+ ParseNonStandardURL(spec, spec_len, &parsed_input);
+ success = CanonicalizeNonStandardURL(
+ spec, spec_len, parsed_input, charset_converter, output, output_parsed);
}
return success;
}
« no previous file with comments | « url/url_canon_etc.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698