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

Side by Side Diff: components/search_engines/template_url.cc

Issue 1093833002: Fixed TemplateURL::ReplaceSearchTermsInURL for non-alphanumeric terms. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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 | components/search_engines/template_url_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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "components/search_engines/template_url.h" 5 #include "components/search_engines/template_url.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 1412 matching lines...) Expand 10 before | Expand all | Expand 10 after
1423 if (search_term_component == url::Parsed::QUERY) { 1423 if (search_term_component == url::Parsed::QUERY) {
1424 old_params = url.query(); 1424 old_params = url.query();
1425 } else if (search_term_component == url::Parsed::REF) { 1425 } else if (search_term_component == url::Parsed::REF) {
1426 old_params = url.ref(); 1426 old_params = url.ref();
1427 } else { 1427 } else {
1428 DCHECK_EQ(search_term_component, url::Parsed::PATH); 1428 DCHECK_EQ(search_term_component, url::Parsed::PATH);
1429 old_params = url.path(); 1429 old_params = url.path();
1430 } 1430 }
1431 1431
1432 std::string new_params(old_params, 0, search_terms_position.begin); 1432 std::string new_params(old_params, 0, search_terms_position.begin);
1433 new_params += base::UTF16ToUTF8(search_terms_args.search_terms); 1433 new_params += base::UTF16ToUTF8(encoded_terms);
1434 new_params += old_params.substr(search_terms_position.end()); 1434 new_params += old_params.substr(search_terms_position.end());
1435 GURL::Replacements replacements; 1435 GURL::Replacements replacements;
1436 1436
1437 if (search_term_component == url::Parsed::QUERY) { 1437 if (search_term_component == url::Parsed::QUERY) {
1438 replacements.SetQueryStr(new_params); 1438 replacements.SetQueryStr(new_params);
1439 } else if (search_term_component == url::Parsed::REF) { 1439 } else if (search_term_component == url::Parsed::REF) {
1440 replacements.SetRefStr(new_params); 1440 replacements.SetRefStr(new_params);
1441 } else { 1441 } else {
1442 DCHECK_EQ(search_term_component, url::Parsed::PATH); 1442 DCHECK_EQ(search_term_component, url::Parsed::PATH);
1443 replacements.SetPathStr(new_params); 1443 replacements.SetPathStr(new_params);
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
1543 // patterns. This means that given patterns 1543 // patterns. This means that given patterns
1544 // [ "http://foo/#q={searchTerms}", "http://foo/?q={searchTerms}" ], 1544 // [ "http://foo/#q={searchTerms}", "http://foo/?q={searchTerms}" ],
1545 // calling ExtractSearchTermsFromURL() on "http://foo/?q=bar#q=' would 1545 // calling ExtractSearchTermsFromURL() on "http://foo/?q=bar#q=' would
1546 // return false. This is important for at least Google, where such URLs 1546 // return false. This is important for at least Google, where such URLs
1547 // are invalid. 1547 // are invalid.
1548 return !search_terms->empty(); 1548 return !search_terms->empty();
1549 } 1549 }
1550 } 1550 }
1551 return false; 1551 return false;
1552 } 1552 }
OLDNEW
« no previous file with comments | « no previous file | components/search_engines/template_url_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698