|
87 | 87 | #include "base64.h" |
88 | 88 |
|
89 | 89 | /* aaaack but it's fast and const should make it shared text page. */ |
| 90 | +/* Modified to support both Base64 (+/) and Base64URL (-_) per RFC 4648 */ |
90 | 91 | static const unsigned char pr2six[256] = |
91 | 92 | { |
92 | 93 | /* ASCII table */ |
93 | 94 | 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, |
94 | 95 | 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, |
95 | | - 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 62, 64, 63, |
| 96 | + /* sp ! " # $ % & ' ( ) * + , - . / */ |
| 97 | + 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 62, 64, 62, 64, 63, |
96 | 98 | 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 64, 64, 64, 64, 64, 64, |
97 | 99 | 64, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, |
98 | 100 | 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 64, 64, 64, 64, 63, |
@@ -149,7 +151,7 @@ int Base64decode(char *bufplain, const char *bufcoded) |
149 | 151 | nprbytes -= 4; |
150 | 152 | } |
151 | 153 |
|
152 | | - /* Note: (nprbytes == 1) would be an error, so just ingore that case */ |
| 154 | + /* Note: (nprbytes == 1) would be an error, so just ignore that case */ |
153 | 155 | if (nprbytes > 1) { |
154 | 156 | *(bufout++) = |
155 | 157 | (unsigned char) (pr2six[*bufin] << 2 | pr2six[bufin[1]] >> 4); |
|
0 commit comments