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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 * Copyright (C) 2012 Motorola Mobility Inc. 3 * Copyright (C) 2012 Motorola Mobility Inc.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 8 *
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 return; 114 return;
115 kurl.setPath(value); 115 kurl.setPath(value);
116 setURL(kurl); 116 setURL(kurl);
117 } 117 }
118 118
119 void DOMURLUtils::setSearch(const String& value) 119 void DOMURLUtils::setSearch(const String& value)
120 { 120 {
121 KURL kurl = url(); 121 KURL kurl = url();
122 if (!kurl.isValid()) 122 if (!kurl.isValid())
123 return; 123 return;
124 kurl.setQuery(value); 124
125 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
126 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
127 else
128 kurl.setQuery(value.isEmpty() ? String() : value);
129
125 setURL(kurl); 130 setURL(kurl);
126 } 131 }
127 132
128 void DOMURLUtils::setHash(const String& value) 133 void DOMURLUtils::setHash(const String& value)
129 { 134 {
130 KURL kurl = url(); 135 KURL kurl = url();
131 if (kurl.isNull()) 136 if (kurl.isNull())
132 return; 137 return;
133 138
134 if (value[0] == '#') 139 if (value[0] == '#')
135 kurl.setFragmentIdentifier(value.substring(1)); 140 kurl.setFragmentIdentifier(value.length() == 1 ? String() : value.substr ing(1));
136 else 141 else
137 kurl.setFragmentIdentifier(value); 142 kurl.setFragmentIdentifier(value.isEmpty() ? String() : value);
138 143
139 setURL(kurl); 144 setURL(kurl);
140 } 145 }
141 146
142 } // namespace blink 147 } // namespace blink
OLDNEW
« 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