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

Side by Side Diff: net/base/escape.cc

Issue 112963005: Update uses of UTF conversions in courgette/, device/, extensions/, google_apis/, gpu/, ipc/, media… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 12 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 | « media/midi/midi_manager_win.cc ('k') | net/base/escape_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 "net/base/escape.h" 5 #include "net/base/escape.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 const char* ampersand_code; 330 const char* ampersand_code;
331 const char replacement; 331 const char replacement;
332 } kEscapeToChars[] = { 332 } kEscapeToChars[] = {
333 { "&lt;", '<' }, 333 { "&lt;", '<' },
334 { "&gt;", '>' }, 334 { "&gt;", '>' },
335 { "&amp;", '&' }, 335 { "&amp;", '&' },
336 { "&quot;", '"' }, 336 { "&quot;", '"' },
337 { "&#39;", '\''}, 337 { "&#39;", '\''},
338 }; 338 };
339 339
340 if (input.find(ASCIIToUTF16("&")) == std::string::npos) 340 if (input.find(base::ASCIIToUTF16("&")) == std::string::npos)
341 return input; 341 return input;
342 342
343 base::string16 ampersand_chars[ARRAYSIZE_UNSAFE(kEscapeToChars)]; 343 base::string16 ampersand_chars[ARRAYSIZE_UNSAFE(kEscapeToChars)];
344 base::string16 text(input); 344 base::string16 text(input);
345 for (base::string16::iterator iter = text.begin(); 345 for (base::string16::iterator iter = text.begin();
346 iter != text.end(); ++iter) { 346 iter != text.end(); ++iter) {
347 if (*iter == '&') { 347 if (*iter == '&') {
348 // Potential ampersand encode char. 348 // Potential ampersand encode char.
349 size_t index = iter - text.begin(); 349 size_t index = iter - text.begin();
350 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kEscapeToChars); i++) { 350 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kEscapeToChars); i++) {
351 if (ampersand_chars[i].empty()) 351 if (ampersand_chars[i].empty()) {
352 ampersand_chars[i] = ASCIIToUTF16(kEscapeToChars[i].ampersand_code); 352 ampersand_chars[i] =
353 base::ASCIIToUTF16(kEscapeToChars[i].ampersand_code);
354 }
353 if (text.find(ampersand_chars[i], index) == index) { 355 if (text.find(ampersand_chars[i], index) == index) {
354 text.replace(iter, iter + ampersand_chars[i].length(), 356 text.replace(iter, iter + ampersand_chars[i].length(),
355 1, kEscapeToChars[i].replacement); 357 1, kEscapeToChars[i].replacement);
356 break; 358 break;
357 } 359 }
358 } 360 }
359 } 361 }
360 } 362 }
361 return text; 363 return text;
362 } 364 }
(...skipping 20 matching lines...) Expand all
383 return; 385 return;
384 } 386 }
385 adjusted_offset -= 2; 387 adjusted_offset -= 2;
386 } 388 }
387 offset = adjusted_offset; 389 offset = adjusted_offset;
388 } 390 }
389 391
390 } // namespace internal 392 } // namespace internal
391 393
392 } // namespace net 394 } // namespace net
OLDNEW
« no previous file with comments | « media/midi/midi_manager_win.cc ('k') | net/base/escape_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698