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

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

Issue 56053: URL's not properly unescaping when displayed (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 11 years, 6 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 | « net/base/escape.h ('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) 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 <algorithm> 5 #include <algorithm>
6 6
7 #include "net/base/escape.h" 7 #include "net/base/escape.h"
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 // P Q R S T U V W X Y Z [ \ ] ^ _ 100 // P Q R S T U V W X Y Z [ \ ] ^ _
101 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 101 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
102 // ` a b c d e f g h i j k l m n o 102 // ` a b c d e f g h i j k l m n o
103 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 103 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
104 // p q r s t u v w x y z { | } ~ <NBSP> 104 // p q r s t u v w x y z { | } ~ <NBSP>
105 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 105 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0
106 }; 106 };
107 107
108 std::string UnescapeURLImpl(const std::string& escaped_text, 108 std::string UnescapeURLImpl(const std::string& escaped_text,
109 UnescapeRule::Type rules) { 109 UnescapeRule::Type rules) {
110 // Do not unescape anything, return the |escaped_text| text.
111 if (rules == UnescapeRule::NONE)
112 return escaped_text;
113
110 // The output of the unescaping is always smaller than the input, so we can 114 // The output of the unescaping is always smaller than the input, so we can
111 // reserve the input size to make sure we have enough buffer and don't have 115 // reserve the input size to make sure we have enough buffer and don't have
112 // to allocate in the loop below. 116 // to allocate in the loop below.
113 std::string result; 117 std::string result;
114 result.reserve(escaped_text.length()); 118 result.reserve(escaped_text.length());
115 119
116 for (size_t i = 0, max = escaped_text.size(); i < max; ++i) { 120 for (size_t i = 0, max = escaped_text.size(); i < max; ++i) {
117 if (escaped_text[i] == '%' && i + 2 < max) { 121 if (escaped_text[i] == '%' && i + 2 < max) {
118 const std::string::value_type most_sig_digit(escaped_text[i + 1]); 122 const std::string::value_type most_sig_digit(escaped_text[i + 1]);
119 const std::string::value_type least_sig_digit(escaped_text[i + 2]); 123 const std::string::value_type least_sig_digit(escaped_text[i + 2]);
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 return result; 279 return result;
276 } 280 }
277 281
278 std::string EscapeForHTML(const std::string& input) { 282 std::string EscapeForHTML(const std::string& input) {
279 return EscapeForHTMLImpl(input); 283 return EscapeForHTMLImpl(input);
280 } 284 }
281 285
282 std::wstring EscapeForHTML(const std::wstring& input) { 286 std::wstring EscapeForHTML(const std::wstring& input) {
283 return EscapeForHTMLImpl(input); 287 return EscapeForHTMLImpl(input);
284 } 288 }
OLDNEW
« no previous file with comments | « net/base/escape.h ('k') | net/base/escape_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698