summaryrefslogtreecommitdiffstats
path: root/url/url_util.cc
diff options
context:
space:
mode:
authorjoth@chromium.org <joth@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-23 01:53:52 +0000
committerjoth@chromium.org <joth@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-23 01:53:52 +0000
commit369e84f70d256d188a1866d8cef52edf4468cd9b (patch)
treee7e90408125f4831ce7983fd37414ad763b965b1 /url/url_util.cc
parenta7e3691579181327dc65b02d043e7c01d4b06cb9 (diff)
downloadchromium_src-369e84f70d256d188a1866d8cef52edf4468cd9b.zip
chromium_src-369e84f70d256d188a1866d8cef52edf4468cd9b.tar.gz
chromium_src-369e84f70d256d188a1866d8cef52edf4468cd9b.tar.bz2
Support URL fragment resolution against non-hierarchical schemes
Support URL fragment resolution against non-hierarchical schemes As a result, data: about: etc now have 'query' and 'ref' components parsed; as a result a new GURL::GetContent() convenience is added to retrieve the spec with the scheme stripped off. A complication in supporting this is that we now need to allow whitespace to trailing whitespace to be preserved when transferring url_parse::Parsed structs between KURL and GURL. Without this, the URL prior to the #fragment can change (i.e. whitespace stripped) when following an anchor link which breaks the page (causes reload from source). See http://crbug.com/291747 for more details on this. R=brettw@chromium.org TBR=cbentzel@chromium.org BUG=291747 Review URL: https://codereview.chromium.org/23835019 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@236917 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'url/url_util.cc')
-rw-r--r--url/url_util.cc16
1 files changed, 10 insertions, 6 deletions
diff --git a/url/url_util.cc b/url/url_util.cc
index f16af98..2b4f7ad 100644
--- a/url/url_util.cc
+++ b/url/url_util.cc
@@ -121,6 +121,7 @@ bool DoFindAndCompareScheme(const CHAR* str,
template<typename CHAR>
bool DoCanonicalize(const CHAR* in_spec, int in_spec_len,
+ bool trim_path_end,
url_canon::CharsetConverter* charset_converter,
url_canon::CanonOutput* output,
url_parse::Parsed* output_parsed) {
@@ -188,7 +189,7 @@ bool DoCanonicalize(const CHAR* in_spec, int in_spec_len,
} else {
// "Weird" URLs like data: and javascript:
- url_parse::ParsePathURL(spec, spec_len, &parsed_input);
+ url_parse::ParsePathURL(spec, spec_len, trim_path_end, &parsed_input);
success = url_canon::CanonicalizePathURL(spec, spec_len, parsed_input,
output, output_parsed);
}
@@ -252,7 +253,8 @@ bool DoResolveRelative(const char* base_spec,
// The output_parsed is incorrect at this point (because it was built
// based on base_parsed_authority instead of base_parsed) and needs to be
// re-created.
- ParsePathURL(output->data(), output->length(), output_parsed);
+ ParsePathURL(output->data(), output->length(), true,
+ output_parsed);
return did_resolve_succeed;
}
} else if (is_relative) {
@@ -266,7 +268,7 @@ bool DoResolveRelative(const char* base_spec,
}
// Not relative, canonicalize the input.
- return DoCanonicalize(relative, relative_length, charset_converter,
+ return DoCanonicalize(relative, relative_length, true, charset_converter,
output, output_parsed);
}
@@ -314,7 +316,7 @@ bool DoReplaceComponents(const char* spec,
// may have changed with the different scheme.
url_canon::RawCanonOutput<128> recanonicalized;
url_parse::Parsed recanonicalized_parsed;
- DoCanonicalize(scheme_replaced.data(), scheme_replaced.length(),
+ DoCanonicalize(scheme_replaced.data(), scheme_replaced.length(), true,
charset_converter,
&recanonicalized, &recanonicalized_parsed);
@@ -429,19 +431,21 @@ bool FindAndCompareScheme(const base::char16* str,
bool Canonicalize(const char* spec,
int spec_len,
+ bool trim_path_end,
url_canon::CharsetConverter* charset_converter,
url_canon::CanonOutput* output,
url_parse::Parsed* output_parsed) {
- return DoCanonicalize(spec, spec_len, charset_converter,
+ return DoCanonicalize(spec, spec_len, trim_path_end, charset_converter,
output, output_parsed);
}
bool Canonicalize(const base::char16* spec,
int spec_len,
+ bool trim_path_end,
url_canon::CharsetConverter* charset_converter,
url_canon::CanonOutput* output,
url_parse::Parsed* output_parsed) {
- return DoCanonicalize(spec, spec_len, charset_converter,
+ return DoCanonicalize(spec, spec_len, trim_path_end, charset_converter,
output, output_parsed);
}