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 17 matching lines...) Expand all Loading... |
28 */ | 28 */ |
29 | 29 |
30 #ifndef DecodeEscapeSequences_h | 30 #ifndef DecodeEscapeSequences_h |
31 #define DecodeEscapeSequences_h | 31 #define DecodeEscapeSequences_h |
32 | 32 |
33 #include "wtf/ASCIICType.h" | 33 #include "wtf/ASCIICType.h" |
34 #include "wtf/Assertions.h" | 34 #include "wtf/Assertions.h" |
35 #include "wtf/text/StringBuilder.h" | 35 #include "wtf/text/StringBuilder.h" |
36 #include "wtf/text/TextEncoding.h" | 36 #include "wtf/text/TextEncoding.h" |
37 | 37 |
38 namespace WebCore { | 38 namespace blink { |
39 | 39 |
40 // See <http://en.wikipedia.org/wiki/Percent-encoding#Non-standard_implementatio
ns>. | 40 // See <http://en.wikipedia.org/wiki/Percent-encoding#Non-standard_implementatio
ns>. |
41 struct Unicode16BitEscapeSequence { | 41 struct Unicode16BitEscapeSequence { |
42 enum { sequenceSize = 6 }; // e.g. %u26C4 | 42 enum { sequenceSize = 6 }; // e.g. %u26C4 |
43 static size_t findInString(const String& string, size_t startPosition) { ret
urn string.find("%u", startPosition); } | 43 static size_t findInString(const String& string, size_t startPosition) { ret
urn string.find("%u", startPosition); } |
44 static size_t findEndOfRun(const String& string, size_t startPosition, size_
t endPosition) | 44 static size_t findEndOfRun(const String& string, size_t startPosition, size_
t endPosition) |
45 { | 45 { |
46 size_t runEnd = startPosition; | 46 size_t runEnd = startPosition; |
47 while (endPosition - runEnd >= sequenceSize && string[runEnd] == '%' &&
string[runEnd + 1] == 'u' | 47 while (endPosition - runEnd >= sequenceSize && string[runEnd] == '%' &&
string[runEnd + 1] == 'u' |
48 && isASCIIHexDigit(string[runEnd + 2]) && isASCIIHexDigit(string[
runEnd + 3]) | 48 && isASCIIHexDigit(string[runEnd + 2]) && isASCIIHexDigit(string[
runEnd + 3]) |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 continue; | 146 continue; |
147 | 147 |
148 result.append(string, decodedPosition, encodedRunPosition - decodedPosit
ion); | 148 result.append(string, decodedPosition, encodedRunPosition - decodedPosit
ion); |
149 result.append(decoded); | 149 result.append(decoded); |
150 decodedPosition = encodedRunEnd; | 150 decodedPosition = encodedRunEnd; |
151 } | 151 } |
152 result.append(string, decodedPosition, length - decodedPosition); | 152 result.append(string, decodedPosition, length - decodedPosition); |
153 return result.toString(); | 153 return result.toString(); |
154 } | 154 } |
155 | 155 |
156 } // namespace WebCore | 156 } // namespace blink |
157 | 157 |
158 #endif // DecodeEscapeSequences_h | 158 #endif // DecodeEscapeSequences_h |
OLD | NEW |