OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Daniel Bates (dbates@intudata.com). All Rights Reserved. | 2 * Copyright (C) 2011 Daniel Bates (dbates@intudata.com). All Rights Reserved. |
3 * Copyright (c) 2012 Google, inc. All Rights Reserved. | 3 * Copyright (c) 2012 Google, inc. All Rights Reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 const CharType* run_end = run + run_length; | 132 const CharType* run_end = run + run_length; |
133 while (run < run_end) { | 133 while (run < run_end) { |
134 if (run[0] == '%') { | 134 if (run[0] == '%') { |
135 *p++ = (ToASCIIHexValue(run[1]) << 4) | ToASCIIHexValue(run[2]); | 135 *p++ = (ToASCIIHexValue(run[1]) << 4) | ToASCIIHexValue(run[2]); |
136 run += kSequenceSize; | 136 run += kSequenceSize; |
137 } else { | 137 } else { |
138 *p++ = run[0]; | 138 *p++ = run[0]; |
139 run += 1; | 139 run += 1; |
140 } | 140 } |
141 } | 141 } |
142 ASSERT( | 142 DCHECK_GE( |
143 buffer.size() >= | 143 buffer.size(), |
144 static_cast<size_t>(p - buffer.Data())); // Prove buffer not overrun. | 144 static_cast<size_t>(p - buffer.Data())); // Prove buffer not overrun. |
145 return (encoding.IsValid() ? encoding : UTF8Encoding()) | 145 return (encoding.IsValid() ? encoding : UTF8Encoding()) |
146 .Decode(buffer.Data(), p - buffer.Data()); | 146 .Decode(buffer.Data(), p - buffer.Data()); |
147 } | 147 } |
148 }; | 148 }; |
149 | 149 |
150 template <typename EscapeSequence> | 150 template <typename EscapeSequence> |
151 String DecodeEscapeSequences(const String& string, | 151 String DecodeEscapeSequences(const String& string, |
152 const WTF::TextEncoding& encoding) { | 152 const WTF::TextEncoding& encoding) { |
153 StringBuilder result; | 153 StringBuilder result; |
(...skipping 27 matching lines...) Expand all Loading... |
181 result.Append(decoded); | 181 result.Append(decoded); |
182 decoded_position = encoded_run_end; | 182 decoded_position = encoded_run_end; |
183 } | 183 } |
184 result.Append(string, decoded_position, length - decoded_position); | 184 result.Append(string, decoded_position, length - decoded_position); |
185 return result.ToString(); | 185 return result.ToString(); |
186 } | 186 } |
187 | 187 |
188 } // namespace blink | 188 } // namespace blink |
189 | 189 |
190 #endif // DecodeEscapeSequences_h | 190 #endif // DecodeEscapeSequences_h |
OLD | NEW |