| 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;
|
| }
|
|
|