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

Side by Side Diff: url/url_canon_relative.cc

Issue 2890143002: Set 'whitespace_removed' correctly when resolving relative URLs. (Closed)
Patch Set: Test. Created 3 years, 7 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 unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/platform/weborigin/KURLTest.cpp ('k') | url/url_util_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Canonicalizer functions for working with and resolving relative URLs. 5 // Canonicalizer functions for working with and resolving relative URLs.
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "url/url_canon.h" 10 #include "url/url_canon.h"
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 // TODO(brettw) treat two slashes as root like Mozilla for FTP? 434 // TODO(brettw) treat two slashes as root like Mozilla for FTP?
435 template<typename CHAR> 435 template<typename CHAR>
436 bool DoResolveRelativeURL(const char* base_url, 436 bool DoResolveRelativeURL(const char* base_url,
437 const Parsed& base_parsed, 437 const Parsed& base_parsed,
438 bool base_is_file, 438 bool base_is_file,
439 const CHAR* relative_url, 439 const CHAR* relative_url,
440 const Component& relative_component, 440 const Component& relative_component,
441 CharsetConverter* query_converter, 441 CharsetConverter* query_converter,
442 CanonOutput* output, 442 CanonOutput* output,
443 Parsed* out_parsed) { 443 Parsed* out_parsed) {
444 // Starting point for our output parsed. We'll fix what we change. 444 // |base_parsed| is the starting point for our output. Since we may have
445 // removed whitespace from |relative_url| before entering this method, we'll
446 // carry over the |whitespace_removed| flag.
447 bool whitespace_removed = out_parsed->whitespace_removed;
445 *out_parsed = base_parsed; 448 *out_parsed = base_parsed;
449 if (whitespace_removed)
450 out_parsed->whitespace_removed = true;
446 451
447 // Sanity check: the input should have a host or we'll break badly below. 452 // Sanity check: the input should have a host or we'll break badly below.
448 // We can only resolve relative URLs with base URLs that have hosts and 453 // We can only resolve relative URLs with base URLs that have hosts and
449 // paths (even the default path of "/" is OK). 454 // paths (even the default path of "/" is OK).
450 // 455 //
451 // We allow hosts with no length so we can handle file URLs, for example. 456 // We allow hosts with no length so we can handle file URLs, for example.
452 if (base_parsed.path.len <= 0) { 457 if (base_parsed.path.len <= 0) {
453 // On error, return the input (resolving a relative URL on a non-relative 458 // On error, return the input (resolving a relative URL on a non-relative
454 // base = the base). 459 // base = the base).
455 int base_len = base_parsed.Length(); 460 int base_len = base_parsed.Length();
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 const Component& relative_component, 573 const Component& relative_component,
569 CharsetConverter* query_converter, 574 CharsetConverter* query_converter,
570 CanonOutput* output, 575 CanonOutput* output,
571 Parsed* out_parsed) { 576 Parsed* out_parsed) {
572 return DoResolveRelativeURL<base::char16>( 577 return DoResolveRelativeURL<base::char16>(
573 base_url, base_parsed, base_is_file, relative_url, 578 base_url, base_parsed, base_is_file, relative_url,
574 relative_component, query_converter, output, out_parsed); 579 relative_component, query_converter, output, out_parsed);
575 } 580 }
576 581
577 } // namespace url 582 } // namespace url
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/weborigin/KURLTest.cpp ('k') | url/url_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698