| 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* runEnd = run + runLength; | 132 const CharType* runEnd = run + runLength; |
| 133 while (run < runEnd) { | 133 while (run < runEnd) { |
| 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 += sequenceSize; | 136 run += sequenceSize; |
| 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 decodedPosition = encodedRunEnd; | 182 decodedPosition = encodedRunEnd; |
| 183 } | 183 } |
| 184 result.append(string, decodedPosition, length - decodedPosition); | 184 result.append(string, decodedPosition, length - decodedPosition); |
| 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 |