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

Side by Side Diff: chrome/browser/search_engines/template_url.cc

Issue 159707: Fixes bug in creating search terms where we weren't unescaping... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/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 (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 "chrome/browser/search_engines/template_url.h" 5 #include "chrome/browser/search_engines/template_url.h"
6 6
7 #include "app/gfx/favicon_size.h" 7 #include "app/gfx/favicon_size.h"
8 #include "app/l10n_util.h" 8 #include "app/l10n_util.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 ParseIfNecessary(); 392 ParseIfNecessary();
393 return search_term_key_; 393 return search_term_key_;
394 } 394 }
395 395
396 std::wstring TemplateURLRef::SearchTermToWide(const TemplateURL& host, 396 std::wstring TemplateURLRef::SearchTermToWide(const TemplateURL& host,
397 const std::string& term) const { 397 const std::string& term) const {
398 const std::vector<std::string>& encodings = host.input_encodings(); 398 const std::vector<std::string>& encodings = host.input_encodings();
399 std::wstring result; 399 std::wstring result;
400 400
401 std::string unescaped = 401 std::string unescaped =
402 UnescapeURLComponent(term, UnescapeRule::REPLACE_PLUS_WITH_SPACE); 402 UnescapeURLComponent(term, UnescapeRule::REPLACE_PLUS_WITH_SPACE |
403 UnescapeRule::URL_SPECIAL_CHARS);
403 for (size_t i = 0; i < encodings.size(); ++i) { 404 for (size_t i = 0; i < encodings.size(); ++i) {
404 if (CodepageToWide(unescaped, encodings[i].c_str(), 405 if (CodepageToWide(unescaped, encodings[i].c_str(),
405 OnStringUtilConversionError::FAIL, &result)) 406 OnStringUtilConversionError::FAIL, &result))
406 return result; 407 return result;
407 } 408 }
408 409
409 // Always fall back on UTF-8 if it works. 410 // Always fall back on UTF-8 if it works.
410 if (CodepageToWide(unescaped, "UTF-8", 411 if (CodepageToWide(unescaped, "UTF-8",
411 OnStringUtilConversionError::FAIL, &result)) 412 OnStringUtilConversionError::FAIL, &result))
412 return result; 413 return result;
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
567 } 568 }
568 return GURL(); 569 return GURL();
569 } 570 }
570 571
571 void TemplateURL::InvalidateCachedValues() const { 572 void TemplateURL::InvalidateCachedValues() const {
572 url_.InvalidateCachedValues(); 573 url_.InvalidateCachedValues();
573 suggestions_url_.InvalidateCachedValues(); 574 suggestions_url_.InvalidateCachedValues();
574 if (autogenerate_keyword_) 575 if (autogenerate_keyword_)
575 keyword_.clear(); 576 keyword_.clear();
576 } 577 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/search_engines/template_url_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698