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

Unified Diff: Source/core/dom/DOMURLUtils.cpp

Issue 537103002: Spec compliant url.search/url.hash setters over empty values. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Update HTMLAnchorElement tests Created 6 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 | « LayoutTests/platform/win/fast/dom/HTMLAnchorElement/set-href-attribute-search-expected.txt ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/DOMURLUtils.cpp
diff --git a/Source/core/dom/DOMURLUtils.cpp b/Source/core/dom/DOMURLUtils.cpp
index a3940bb17a5eedd78cfd3d168fbf4fccb1bab973..e3ba74039b0828aa9f671d65431ee2684ff6d238 100644
--- a/Source/core/dom/DOMURLUtils.cpp
+++ b/Source/core/dom/DOMURLUtils.cpp
@@ -121,7 +121,12 @@ void DOMURLUtils::setSearch(const String& value)
KURL kurl = url();
if (!kurl.isValid())
return;
- kurl.setQuery(value);
+
+ if (value[0] == '?')
arv (Not doing code reviews) 2014/09/03 22:08:36 Do we need to handle length 0 before this test?
sof 2014/09/04 06:52:24 No real need, [] returns 0 over out-of-bounds indi
+ kurl.setQuery(value.length() == 1 ? String() : value.substring(1));
arv (Not doing code reviews) 2014/09/03 22:08:36 I thought KURL::setQuery did this? https://code.g
sof 2014/09/04 06:52:24 That handling strips the leading '?', but doesn't
+ else
+ kurl.setQuery(value.isEmpty() ? String() : value);
+
setURL(kurl);
}
@@ -132,9 +137,9 @@ void DOMURLUtils::setHash(const String& value)
return;
if (value[0] == '#')
- kurl.setFragmentIdentifier(value.substring(1));
+ kurl.setFragmentIdentifier(value.length() == 1 ? String() : value.substring(1));
else
- kurl.setFragmentIdentifier(value);
+ kurl.setFragmentIdentifier(value.isEmpty() ? String() : value);
setURL(kurl);
}
« no previous file with comments | « LayoutTests/platform/win/fast/dom/HTMLAnchorElement/set-href-attribute-search-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698