Changeset 158933 in webkit
- Timestamp:
- Nov 8, 2013, 11:37:57 AM (12 years ago)
- Location:
- trunk/Source/WTF
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WTF/ChangeLog
r158848 r158933 1 2013-11-08 Alexey Proskuryakov <ap@apple.com> 2 3 Make base64url decoding actually work 4 https://bugs.webkit.org/show_bug.cgi?id=124050 5 6 Reviewed by Sam Weinig. 7 8 * wtf/text/Base64.cpp: (WTF::base64DecodeInternal): Don't hardcode knowledge about 9 alphabet, put it into the map. 10 1 11 2013-11-07 Denis Nomiyama <d.nomiyama@samsung.com> 2 12 -
trunk/Source/WTF/wtf/text/Base64.cpp
r158628 r158933 30 30 31 31 namespace WTF { 32 33 const char nonAlphabet = -1; 32 34 33 35 static const char base64EncMap[64] = { … … 43 45 44 46 static const char base64DecMap[128] = { 45 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,46 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,47 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,48 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,49 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,50 0x00, 0x00, 0x00, 0x3E, 0x00, 0x00, 0x00, 0x3F,47 nonAlphabet, nonAlphabet, nonAlphabet, nonAlphabet, nonAlphabet, nonAlphabet, nonAlphabet, nonAlphabet, 48 nonAlphabet, nonAlphabet, nonAlphabet, nonAlphabet, nonAlphabet, nonAlphabet, nonAlphabet, nonAlphabet, 49 nonAlphabet, nonAlphabet, nonAlphabet, nonAlphabet, nonAlphabet, nonAlphabet, nonAlphabet, nonAlphabet, 50 nonAlphabet, nonAlphabet, nonAlphabet, nonAlphabet, nonAlphabet, nonAlphabet, nonAlphabet, nonAlphabet, 51 nonAlphabet, nonAlphabet, nonAlphabet, nonAlphabet, nonAlphabet, nonAlphabet, nonAlphabet, nonAlphabet, 52 nonAlphabet, nonAlphabet, nonAlphabet, 0x3E, nonAlphabet, nonAlphabet, nonAlphabet, 0x3F, 51 53 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 52 0x3C, 0x3D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,53 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06,54 0x3C, 0x3D, nonAlphabet, nonAlphabet, nonAlphabet, nonAlphabet, nonAlphabet, nonAlphabet, 55 nonAlphabet, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 54 56 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 55 57 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 56 0x17, 0x18, 0x19, 0x00, 0x00, 0x00, 0x00, 0x00,57 0x00, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20,58 0x17, 0x18, 0x19, nonAlphabet, nonAlphabet, nonAlphabet, nonAlphabet, nonAlphabet, 59 nonAlphabet, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 58 60 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 59 61 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x30, 60 0x31, 0x32, 0x33, 0x00, 0x00, 0x00, 0x00, 0x0062 0x31, 0x32, 0x33, nonAlphabet, nonAlphabet, nonAlphabet, nonAlphabet, nonAlphabet 61 63 }; 62 64 … … 73 75 74 76 static const char base64URLDecMap[128] = { 75 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,76 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,77 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,78 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,79 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,80 0x00, 0x00, 0x00, 0x00, 0x00, 0x3E, 0x00, 0x00,77 nonAlphabet, nonAlphabet, nonAlphabet, nonAlphabet, nonAlphabet, nonAlphabet, nonAlphabet, nonAlphabet, 78 nonAlphabet, nonAlphabet, nonAlphabet, nonAlphabet, nonAlphabet, nonAlphabet, nonAlphabet, nonAlphabet, 79 nonAlphabet, nonAlphabet, nonAlphabet, nonAlphabet, nonAlphabet, nonAlphabet, nonAlphabet, nonAlphabet, 80 nonAlphabet, nonAlphabet, nonAlphabet, nonAlphabet, nonAlphabet, nonAlphabet, nonAlphabet, nonAlphabet, 81 nonAlphabet, nonAlphabet, nonAlphabet, nonAlphabet, nonAlphabet, nonAlphabet, nonAlphabet, nonAlphabet, 82 nonAlphabet, nonAlphabet, nonAlphabet, nonAlphabet, nonAlphabet, 0x3E, nonAlphabet, nonAlphabet, 81 83 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 82 0x3C, 0x3D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,83 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06,84 0x3C, 0x3D, nonAlphabet, nonAlphabet, nonAlphabet, nonAlphabet, nonAlphabet, nonAlphabet, 85 nonAlphabet, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 84 86 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 85 87 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 86 0x17, 0x18, 0x19, 0x00, 0x00, 0x00, 0x00, 0x3F,87 0x00, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20,88 0x17, 0x18, 0x19, nonAlphabet, nonAlphabet, nonAlphabet, nonAlphabet, 0x3F, 89 nonAlphabet, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 88 90 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 89 91 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x30, 90 0x31, 0x32, 0x33, 0x00, 0x00, 0x00, 0x00, 0x0092 0x31, 0x32, 0x33, nonAlphabet, nonAlphabet, nonAlphabet, nonAlphabet, nonAlphabet 91 93 }; 92 94 … … 195 197 if (policy == Base64FailOnInvalidCharacterOrExcessPadding && (length % 4 || equalsSignCount > 2)) 196 198 return false; 197 } else if (('0' <= ch && ch <= '9') || ('A' <= ch && ch <= 'Z') || ('a' <= ch && ch <= 'z') || ch == '+' || ch == '/') { 198 if (equalsSignCount) 199 } else { 200 char decodedCharacter = decodeMap[ch]; 201 if (decodedCharacter != nonAlphabet) { 202 if (equalsSignCount) 203 return false; 204 out[outLength] = decodedCharacter; 205 ++outLength; 206 } else if (policy == Base64FailOnInvalidCharacterOrExcessPadding || policy == Base64FailOnInvalidCharacter || (policy == Base64IgnoreWhitespace && !isSpaceOrNewline(ch))) 199 207 return false; 200 out[outLength] = decodeMap[ch]; 201 ++outLength; 202 } else if (policy == Base64FailOnInvalidCharacterOrExcessPadding || policy == Base64FailOnInvalidCharacter || (policy == Base64IgnoreWhitespace && !isSpaceOrNewline(ch))) 203 return false; 208 } 204 209 } 205 210
Note:
See TracChangeset
for help on using the changeset viewer.