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

Side by Side Diff: chrome/browser/google_apis/drive_api_util.cc

Issue 14352007: Escape backslash (\x5C) for string value of search query. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/google_apis/drive_api_util_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 "chrome/browser/google_apis/drive_api_util.h" 5 #include "chrome/browser/google_apis/drive_api_util.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "chrome/browser/google_apis/drive_switches.h" 9 #include "chrome/browser/google_apis/drive_switches.h"
10 10
11 namespace google_apis { 11 namespace google_apis {
12 namespace util { 12 namespace util {
13 13
14 bool IsDriveV2ApiEnabled() { 14 bool IsDriveV2ApiEnabled() {
15 return CommandLine::ForCurrentProcess()->HasSwitch( 15 return CommandLine::ForCurrentProcess()->HasSwitch(
16 switches::kEnableDriveV2Api); 16 switches::kEnableDriveV2Api);
17 } 17 }
18 18
19 } // namespace util 19 } // namespace util
20 20
21 namespace drive { 21 namespace drive {
22 namespace util { 22 namespace util {
23 23
24 std::string EscapeQueryStringValue(const std::string& str) { 24 std::string EscapeQueryStringValue(const std::string& str) {
25 std::string result; 25 std::string result;
26 ReplaceChars(str, "'", "\\'", &result); 26 result.reserve(str.size());
27 for (size_t i = 0; i < str.size(); ++i) {
28 if (str[i] == '\\' || str[i] == '\'') {
29 result.push_back('\\');
30 }
31 result.push_back(str[i]);
32 }
27 return result; 33 return result;
28 } 34 }
29 35
30 } // namespace util 36 } // namespace util
31 } // namespace drive 37 } // namespace drive
32 } // namespace google_apis 38 } // namespace google_apis
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/google_apis/drive_api_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698