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

Side by Side Diff: url/url_util_unittest.cc

Issue 767713002: DoResolveRelative must not parse mailto schemes as path URLs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Next attempt Created 6 years 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 | « url/url_util.cc ('k') | no next file » | 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 #include "base/macros.h" 5 #include "base/macros.h"
6 #include "testing/gtest/include/gtest/gtest.h" 6 #include "testing/gtest/include/gtest/gtest.h"
7 #include "url/url_canon.h" 7 #include "url/url_canon.h"
8 #include "url/url_canon_stdstring.h" 8 #include "url/url_canon_stdstring.h"
9 #include "url/url_parse.h" 9 #include "url/url_parse.h"
10 #include "url/url_test_utils.h" 10 #include "url/url_test_utils.h"
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 strlen(test_data.rel), NULL, &output, 288 strlen(test_data.rel), NULL, &output,
289 &resolved_parsed); 289 &resolved_parsed);
290 output.Complete(); 290 output.Complete();
291 291
292 EXPECT_EQ(test_data.is_valid, valid) << i; 292 EXPECT_EQ(test_data.is_valid, valid) << i;
293 if (test_data.is_valid && valid) 293 if (test_data.is_valid && valid)
294 EXPECT_EQ(test_data.out, resolved) << i; 294 EXPECT_EQ(test_data.out, resolved) << i;
295 } 295 }
296 } 296 }
297 297
298 TEST(URLUtilTest, TestNoRefComponent) {
299 // The hash-mark must be ignored when mailto: scheme is
300 // parsed, even if the url has a base and relative part.
301 const char* base = "mailto://to/";
302 const char* rel = "any#body";
303
304 Parsed base_parsed;
305 ParsePathURL(base, strlen(base), false, &base_parsed);
306
307 std::string resolved;
308 StdStringCanonOutput output(&resolved);
309 Parsed resolved_parsed;
310
311 bool valid = ResolveRelative(base, strlen(base),
312 base_parsed, rel,
313 strlen(rel), NULL, &output,
314 &resolved_parsed);
315 EXPECT_TRUE(valid);
316 EXPECT_FALSE(resolved_parsed.ref.is_valid());
317 }
318
298 } // namespace url 319 } // namespace url
OLDNEW
« no previous file with comments | « url/url_util.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698