| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/tools/dump_cache/url_utilities.h" | 5 #include "net/tools/dump_cache/url_utilities.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
| 9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
| 10 | 10 |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 case NORMAL: | 80 case NORMAL: |
| 81 if (c == '%') { | 81 if (c == '%') { |
| 82 escape_text.clear(); | 82 escape_text.clear(); |
| 83 state = ESCAPE1; | 83 state = ESCAPE1; |
| 84 } else { | 84 } else { |
| 85 unescaped_url.push_back(c); | 85 unescaped_url.push_back(c); |
| 86 } | 86 } |
| 87 ++iter; | 87 ++iter; |
| 88 break; | 88 break; |
| 89 case ESCAPE1: | 89 case ESCAPE1: |
| 90 if (IsHexDigit(c)) { | 90 if (base::IsHexDigit(c)) { |
| 91 escape_text.push_back(c); | 91 escape_text.push_back(c); |
| 92 state = ESCAPE2; | 92 state = ESCAPE2; |
| 93 ++iter; | 93 ++iter; |
| 94 } else { | 94 } else { |
| 95 // Unexpected, % followed by non-hex chars, pass it through. | 95 // Unexpected, % followed by non-hex chars, pass it through. |
| 96 unescaped_url.push_back('%'); | 96 unescaped_url.push_back('%'); |
| 97 state = NORMAL; | 97 state = NORMAL; |
| 98 } | 98 } |
| 99 break; | 99 break; |
| 100 case ESCAPE2: | 100 case ESCAPE2: |
| 101 if (IsHexDigit(c)) { | 101 if (base::IsHexDigit(c)) { |
| 102 escape_text.push_back(c); | 102 escape_text.push_back(c); |
| 103 bool ok = base::HexStringToInt(escape_text, &escape_value); | 103 bool ok = base::HexStringToInt(escape_text, &escape_value); |
| 104 DCHECK(ok); | 104 DCHECK(ok); |
| 105 unescaped_url.push_back(static_cast<unsigned char>(escape_value)); | 105 unescaped_url.push_back(static_cast<unsigned char>(escape_value)); |
| 106 state = NORMAL; | 106 state = NORMAL; |
| 107 ++iter; | 107 ++iter; |
| 108 } else { | 108 } else { |
| 109 // Unexpected, % followed by non-hex chars, pass it through. | 109 // Unexpected, % followed by non-hex chars, pass it through. |
| 110 unescaped_url.push_back('%'); | 110 unescaped_url.push_back('%'); |
| 111 unescaped_url.append(escape_text); | 111 unescaped_url.append(escape_text); |
| 112 state = NORMAL; | 112 state = NORMAL; |
| 113 } | 113 } |
| 114 break; | 114 break; |
| 115 } | 115 } |
| 116 } | 116 } |
| 117 // Unexpected, % followed by end of string, pass it through. | 117 // Unexpected, % followed by end of string, pass it through. |
| 118 if (state == ESCAPE1 || state == ESCAPE2) { | 118 if (state == ESCAPE1 || state == ESCAPE2) { |
| 119 unescaped_url.push_back('%'); | 119 unescaped_url.push_back('%'); |
| 120 unescaped_url.append(escape_text); | 120 unescaped_url.append(escape_text); |
| 121 } | 121 } |
| 122 return unescaped_url; | 122 return unescaped_url; |
| 123 } | 123 } |
| 124 | 124 |
| 125 } // namespace net | 125 } // namespace net |
| 126 | 126 |
| OLD | NEW |