OLD | NEW |
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 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 } | 283 } |
284 } | 284 } |
285 | 285 |
286 if (first_byte >= 0x80 || // Unescape all high-bit characters. | 286 if (first_byte >= 0x80 || // Unescape all high-bit characters. |
287 // For 7-bit characters, the lookup table tells us all valid chars. | 287 // For 7-bit characters, the lookup table tells us all valid chars. |
288 (kUrlUnescape[first_byte] || | 288 (kUrlUnescape[first_byte] || |
289 // ...and we allow some additional unescaping when flags are set. | 289 // ...and we allow some additional unescaping when flags are set. |
290 (first_byte == ' ' && (rules & UnescapeRule::SPACES)) || | 290 (first_byte == ' ' && (rules & UnescapeRule::SPACES)) || |
291 // Allow any of the prohibited but non-control characters when | 291 // Allow any of the prohibited but non-control characters when |
292 // we're doing "special" chars. | 292 // we're doing "special" chars. |
293 (first_byte > ' ' && (rules & UnescapeRule::URL_SPECIAL_CHARS)) || | 293 ((first_byte == '/' || first_byte == '\\') && |
| 294 (rules & UnescapeRule::PATH_SEPARATORS)) || |
| 295 (first_byte > ' ' && first_byte != '/' && first_byte != '\\' && |
| 296 (rules & UnescapeRule::URL_SPECIAL_CHARS_EXCEPT_PATH_SEPARATORS)) || |
294 // Additionally allow non-display characters if requested. | 297 // Additionally allow non-display characters if requested. |
295 (first_byte < ' ' && | 298 (first_byte < ' ' && |
296 (rules & UnescapeRule::SPOOFING_AND_CONTROL_CHARS)))) { | 299 (rules & UnescapeRule::SPOOFING_AND_CONTROL_CHARS)))) { |
297 // Use the unescaped version of the character. | 300 // Use the unescaped version of the character. |
298 if (adjustments) | 301 if (adjustments) |
299 adjustments->push_back(base::OffsetAdjuster::Adjustment(i, 3, 1)); | 302 adjustments->push_back(base::OffsetAdjuster::Adjustment(i, 3, 1)); |
300 result.push_back(first_byte); | 303 result.push_back(first_byte); |
301 i += 2; | 304 i += 2; |
302 } else { | 305 } else { |
303 // Keep escaped. Append a percent and we'll get the following two | 306 // Keep escaped. Append a percent and we'll get the following two |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
501 1, kEscapeToChars[i].replacement); | 504 1, kEscapeToChars[i].replacement); |
502 break; | 505 break; |
503 } | 506 } |
504 } | 507 } |
505 } | 508 } |
506 } | 509 } |
507 return text; | 510 return text; |
508 } | 511 } |
509 | 512 |
510 } // namespace net | 513 } // namespace net |
OLD | NEW |