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

Unified Diff: url/third_party/mozilla/url_parse.cc

Issue 23526048: Support URL fragment resolution againt non-hierarchical schemes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: clea Created 7 years, 3 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/third_party/mozilla/url_parse.h ('k') | url/url_canon_pathurl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: url/third_party/mozilla/url_parse.cc
diff --git a/url/third_party/mozilla/url_parse.cc b/url/third_party/mozilla/url_parse.cc
index 52c619645d984aaeb98e2bbf85bb62c7316b7371..01d9d21fda2fe78718c09fdf5c2170f7f21aa76d 100644
--- a/url/third_party/mozilla/url_parse.cc
+++ b/url/third_party/mozilla/url_parse.cc
@@ -455,19 +455,22 @@ void DoParseFileSystemURL(const CHAR* spec, int spec_len, Parsed* parsed) {
// Initializes a path URL which is merely a scheme followed by a path. Examples
// include "about:foo" and "javascript:alert('bar');"
template<typename CHAR>
-void DoParsePathURL(const CHAR* spec, int spec_len, Parsed* parsed) {
+void DoParsePathURL(const CHAR* spec, int spec_len, Parsed* parsed,
+ bool trim_tail) {
// Get the non-path and non-scheme parts of the URL out of the way, we never
// use them.
parsed->username.reset();
parsed->password.reset();
parsed->host.reset();
parsed->port.reset();
+ parsed->path.reset();
parsed->query.reset();
parsed->ref.reset();
// Strip leading & trailing spaces and control characters.
int begin = 0;
- TrimURL(spec, &begin, &spec_len);
+ int dummy_spec_len = spec_len;
+ TrimURL(spec, &begin, trim_tail ? &spec_len : &dummy_spec_len);
// Handle empty specs or ones that contain only whitespace or control chars.
if (begin == spec_len) {
@@ -481,19 +484,20 @@ void DoParsePathURL(const CHAR* spec, int spec_len, Parsed* parsed) {
if (ExtractScheme(&spec[begin], spec_len - begin, &parsed->scheme)) {
// Offset the results since we gave ExtractScheme a substring.
parsed->scheme.begin += begin;
-
- // For compatability with the standard URL parser, we treat no path as
- // -1, rather than having a length of 0 (we normally wouldn't care so
- // much for these non-standard URLs).
- if (parsed->scheme.end() == spec_len - 1)
- parsed->path.reset();
- else
- parsed->path = MakeRange(parsed->scheme.end() + 1, spec_len);
+ begin = parsed->scheme.end() + 1;
} else {
- // No scheme found, just path.
parsed->scheme.reset();
- parsed->path = MakeRange(begin, spec_len);
}
+
+ if (begin == spec_len)
+ return;
+ DCHECK_LT(begin, spec_len);
+
+ ParsePath(spec,
+ MakeRange(begin, spec_len),
+ &parsed->path,
+ &parsed->query,
+ &parsed->ref);
}
template<typename CHAR>
@@ -792,6 +796,15 @@ int Parsed::CountCharactersBefore(ComponentType type,
return cur;
}
+Component Parsed::Content() const {
+ const int begin = CountCharactersBefore(USERNAME, false);
+ const int len = Length() - begin;
+ // For compatability with the standard URL parser, we treat no content as
+ // -1, rather than having a length of 0 (we normally wouldn't care so
+ // much for these non-standard URLs).
+ return len ? Component(begin, len) : Component();
+}
+
bool ExtractScheme(const char* url, int url_len, Component* scheme) {
return DoExtractScheme(url, url_len, scheme);
}
@@ -866,12 +879,14 @@ void ParseStandardURL(const base::char16* url, int url_len, Parsed* parsed) {
DoParseStandardURL(url, url_len, parsed);
}
-void ParsePathURL(const char* url, int url_len, Parsed* parsed) {
- DoParsePathURL(url, url_len, parsed);
+void ParsePathURL(const char* url, int url_len, Parsed* parsed,
+ bool trim_tail) {
+ DoParsePathURL(url, url_len, parsed, trim_tail);
}
-void ParsePathURL(const base::char16* url, int url_len, Parsed* parsed) {
- DoParsePathURL(url, url_len, parsed);
+void ParsePathURL(const base::char16* url, int url_len, Parsed* parsed,
+ bool trim_tail) {
+ DoParsePathURL(url, url_len, parsed, trim_tail);
}
void ParseFileSystemURL(const char* url, int url_len, Parsed* parsed) {
« no previous file with comments | « url/third_party/mozilla/url_parse.h ('k') | url/url_canon_pathurl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698