| 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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 // The basic rule is that we can't unescape anything that would changing parsing | 67 // The basic rule is that we can't unescape anything that would changing parsing |
| 68 // like # or ?. We also can't unescape &, =, or + since that could be part of a | 68 // like # or ?. We also can't unescape &, =, or + since that could be part of a |
| 69 // query and that could change the server's parsing of the query. Nor can we | 69 // query and that could change the server's parsing of the query. Nor can we |
| 70 // unescape \ since googleurl will convert it to a /. | 70 // unescape \ since googleurl will convert it to a /. |
| 71 // | 71 // |
| 72 // Lastly, we can't unescape anything that doesn't have a canonical | 72 // Lastly, we can't unescape anything that doesn't have a canonical |
| 73 // representation in a URL. This means that unescaping will change the URL, and | 73 // representation in a URL. This means that unescaping will change the URL, and |
| 74 // you could get different behavior if you copy and paste the URL, or press | 74 // you could get different behavior if you copy and paste the URL, or press |
| 75 // enter in the URL bar. The list of characters that fall into this category | 75 // enter in the URL bar. The list of characters that fall into this category |
| 76 // are the ones labeled PASS (allow either escaped or unescaped) in the big | 76 // are the ones labeled PASS (allow either escaped or unescaped) in the big |
| 77 // lookup table at the top of googleurl/src/url_canon_path.cc. Also, characters | 77 // lookup table at the top of url/url_canon_path.cc. Also, characters |
| 78 // that have CHAR_QUERY set in googleurl/src/url_canon_internal.cc but are not | 78 // that have CHAR_QUERY set in url/url_canon_internal.cc but are not |
| 79 // allowed in query strings according to http://www.ietf.org/rfc/rfc3261.txt are | 79 // allowed in query strings according to http://www.ietf.org/rfc/rfc3261.txt are |
| 80 // not unescaped, to avoid turning a valid url according to spec into an | 80 // not unescaped, to avoid turning a valid url according to spec into an |
| 81 // invalid one. | 81 // invalid one. |
| 82 const char kUrlUnescape[128] = { | 82 const char kUrlUnescape[128] = { |
| 83 // NULL, control chars... | 83 // NULL, control chars... |
| 84 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | 84 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 85 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | 85 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 86 // ' ' ! " # $ % & ' ( ) * + , - . / | 86 // ' ' ! " # $ % & ' ( ) * + , - . / |
| 87 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, | 87 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, |
| 88 // 0 1 2 3 4 5 6 7 8 9 : ; < = > ? | 88 // 0 1 2 3 4 5 6 7 8 9 : ; < = > ? |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 383 return; | 383 return; |
| 384 } | 384 } |
| 385 adjusted_offset -= 2; | 385 adjusted_offset -= 2; |
| 386 } | 386 } |
| 387 offset = adjusted_offset; | 387 offset = adjusted_offset; |
| 388 } | 388 } |
| 389 | 389 |
| 390 } // namespace internal | 390 } // namespace internal |
| 391 | 391 |
| 392 } // namespace net | 392 } // namespace net |
| OLD | NEW |