Chromium Code Reviews| 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); |
| } |