diff options
author | Andras Becsi <andras.becsi@digia.com> | 2014-03-18 13:16:26 +0100 |
---|---|---|
committer | Frederik Gladhorn <frederik.gladhorn@digia.com> | 2014-03-20 15:55:39 +0100 |
commit | 3f0f86b0caed75241fa71c95a5d73bc0164348c5 (patch) | |
tree | 92b9fb00f2e9e90b0be2262093876d4f43b6cd13 /chromium/url/url_canon_pathurl.cc | |
parent | e90d7c4b152c56919d963987e2503f9909a666d2 (diff) | |
download | qtwebengine-chromium-3f0f86b0caed75241fa71c95a5d73bc0164348c5.tar.gz |
Update to new stable branch 1750
This also includes an updated ninja and chromium dependencies
needed on Windows.
Change-Id: Icd597d80ed3fa4425933c9f1334c3c2e31291c42
Reviewed-by: Zoltan Arvai <zarvai@inf.u-szeged.hu>
Reviewed-by: Zeno Albisser <zeno.albisser@digia.com>
Diffstat (limited to 'chromium/url/url_canon_pathurl.cc')
-rw-r--r-- | chromium/url/url_canon_pathurl.cc | 64 |
1 files changed, 41 insertions, 23 deletions
diff --git a/chromium/url/url_canon_pathurl.cc b/chromium/url/url_canon_pathurl.cc index bc681f4d144..8f7dee48f73 100644 --- a/chromium/url/url_canon_pathurl.cc +++ b/chromium/url/url_canon_pathurl.cc @@ -13,6 +13,39 @@ namespace url_canon { namespace { +// Canonicalize the given |component| from |source| into |output| and +// |new_component|. If |separator| is non-zero, it is pre-pended to |ouput| +// prior to the canonicalized component; i.e. for the '?' or '#' characters. +template<typename CHAR, typename UCHAR> +bool DoCanonicalizePathComponent(const CHAR* source, + const url_parse::Component& component, + CHAR seperator, + CanonOutput* output, + url_parse::Component* new_component) { + bool success = true; + if (component.is_valid()) { + if (seperator) + output->push_back(seperator); + // Copy the path using path URL's more lax escaping rules (think for + // javascript:). We convert to UTF-8 and escape non-ASCII, but leave all + // ASCII characters alone. This helps readability of JavaStript. + new_component->begin = output->length(); + int end = component.end(); + for (int i = component.begin; i < end; i++) { + UCHAR uch = static_cast<UCHAR>(source[i]); + if (uch < 0x20 || uch >= 0x80) + success &= AppendUTF8EscapedChar(source, &i, end, output); + else + output->push_back(static_cast<char>(uch)); + } + new_component->len = output->length() - new_component->begin; + } else { + // Empty part. + new_component->reset(); + } + return success; +} + template<typename CHAR, typename UCHAR> bool DoCanonicalizePathURL(const URLComponentSource<CHAR>& source, const url_parse::Parsed& parsed, @@ -28,29 +61,14 @@ bool DoCanonicalizePathURL(const URLComponentSource<CHAR>& source, new_parsed->password.reset(); new_parsed->host.reset(); new_parsed->port.reset(); - - if (parsed.path.is_valid()) { - // Copy the path using path URL's more lax escaping rules (think for - // javascript:). We convert to UTF-8 and escape non-ASCII, but leave all - // ASCII characters alone. This helps readability of JavaStript. - new_parsed->path.begin = output->length(); - int end = parsed.path.end(); - for (int i = parsed.path.begin; i < end; i++) { - UCHAR uch = static_cast<UCHAR>(source.path[i]); - if (uch < 0x20 || uch >= 0x80) - success &= AppendUTF8EscapedChar(source.path, &i, end, output); - else - output->push_back(static_cast<char>(uch)); - } - new_parsed->path.len = output->length() - new_parsed->path.begin; - } else { - // Empty path. - new_parsed->path.reset(); - } - - // Assume there's no query or ref. - new_parsed->query.reset(); - new_parsed->ref.reset(); + // We allow path URLs to have the path, query and fragment components, but we + // will canonicalize each of the via the weaker path URL rules. + success &= DoCanonicalizePathComponent<CHAR, UCHAR>( + source.path, parsed.path, 0, output, &new_parsed->path); + success &= DoCanonicalizePathComponent<CHAR, UCHAR>( + source.query, parsed.query, '?', output, &new_parsed->query); + success &= DoCanonicalizePathComponent<CHAR, UCHAR>( + source.ref, parsed.ref, '#', output, &new_parsed->ref); return success; } |