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

Side by Side Diff: extensions/common/url_pattern.cc

Issue 364703002: Return if a host name in an URLPattern has no non-whitespace characters. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 5 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 | « no previous file | extensions/common/url_pattern_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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "extensions/common/url_pattern.h" 5 #include "extensions/common/url_pattern.h"
6 6
7 #include "base/strings/string_number_conversions.h" 7 #include "base/strings/string_number_conversions.h"
8 #include "base/strings/string_piece.h" 8 #include "base/strings/string_piece.h"
9 #include "base/strings/string_split.h" 9 #include "base/strings/string_split.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 return PARSE_ERROR_EMPTY_HOST; 212 return PARSE_ERROR_EMPTY_HOST;
213 213
214 if (host_end_pos == std::string::npos) 214 if (host_end_pos == std::string::npos)
215 return PARSE_ERROR_EMPTY_PATH; 215 return PARSE_ERROR_EMPTY_PATH;
216 216
217 host_ = pattern.substr(host_start_pos, host_end_pos - host_start_pos); 217 host_ = pattern.substr(host_start_pos, host_end_pos - host_start_pos);
218 218
219 // The first component can optionally be '*' to match all subdomains. 219 // The first component can optionally be '*' to match all subdomains.
220 std::vector<std::string> host_components; 220 std::vector<std::string> host_components;
221 base::SplitString(host_, '.', &host_components); 221 base::SplitString(host_, '.', &host_components);
222
223 // Could be empty if the host only consists of whitespace characters.
224 if (host_components.empty())
225 return PARSE_ERROR_EMPTY_HOST;
226
222 if (host_components[0] == "*") { 227 if (host_components[0] == "*") {
223 match_subdomains_ = true; 228 match_subdomains_ = true;
224 host_components.erase(host_components.begin(), 229 host_components.erase(host_components.begin(),
225 host_components.begin() + 1); 230 host_components.begin() + 1);
226 } 231 }
227 host_ = JoinString(host_components, '.'); 232 host_ = JoinString(host_components, '.');
228 233
229 path_start_pos = host_end_pos; 234 path_start_pos = host_end_pos;
230 } 235 }
231 236
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 } 541 }
537 542
538 return result; 543 return result;
539 } 544 }
540 545
541 // static 546 // static
542 const char* URLPattern::GetParseResultString( 547 const char* URLPattern::GetParseResultString(
543 URLPattern::ParseResult parse_result) { 548 URLPattern::ParseResult parse_result) {
544 return kParseResultMessages[parse_result]; 549 return kParseResultMessages[parse_result];
545 } 550 }
OLDNEW
« no previous file with comments | « no previous file | extensions/common/url_pattern_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698