OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
4 * (C) 2001 Dirk Mueller (mueller@kde.org) | 4 * (C) 2001 Dirk Mueller (mueller@kde.org) |
5 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. | 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. |
6 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) | 6 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) |
7 * Copyright (C) 2008 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/) | 7 * Copyright (C) 2008 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/) |
8 * | 8 * |
9 * This library is free software; you can redistribute it and/or | 9 * This library is free software; you can redistribute it and/or |
10 * modify it under the terms of the GNU Library General Public | 10 * modify it under the terms of the GNU Library General Public |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
92 if (charset.isEmpty()) { | 92 if (charset.isEmpty()) { |
93 if (defaultCharset.isEmpty()) | 93 if (defaultCharset.isEmpty()) |
94 return WTF::UTF8Encoding(); | 94 return WTF::UTF8Encoding(); |
95 | 95 |
96 return defaultCharset; | 96 return defaultCharset; |
97 } | 97 } |
98 | 98 |
99 return charset; | 99 return charset; |
100 } | 100 } |
101 | 101 |
102 // TODO(lukasza): Reuse net::GenerateMimeMultipartBoundary instead. | |
Łukasz Anforowicz
2016/01/08 21:31:12
Hmmm... ideally we would have only 1 piece of code
Ryan Sleevi
2016/01/08 21:34:22
No, we don't want base/ to be the dumping ground f
| |
103 Vector<char> FormDataEncoder::generateUniqueBoundaryString() | 102 Vector<char> FormDataEncoder::generateUniqueBoundaryString() |
104 { | 103 { |
105 Vector<char> boundary; | 104 Vector<char> boundary; |
106 | 105 |
106 // TODO(rsleevi): crbug.com/575779: Follow the spec or fix the spec. | |
107 // The RFC 2046 spec says the alphanumeric characters plus the | 107 // The RFC 2046 spec says the alphanumeric characters plus the |
108 // following characters are legal for boundaries: '()+_,-./:=? | 108 // following characters are legal for boundaries: '()+_,-./:=? |
109 // However the following characters, though legal, cause some sites | 109 // However the following characters, though legal, cause some sites |
110 // to fail: (),./:=+ | 110 // to fail: (),./:=+ |
111 // | |
111 // Note that our algorithm makes it twice as much likely for 'A' or 'B' | 112 // Note that our algorithm makes it twice as much likely for 'A' or 'B' |
112 // to appear in the boundary string, because 0x41 and 0x42 are present in | 113 // to appear in the boundary string, because 0x41 and 0x42 are present in |
113 // the below array twice. | 114 // the below array twice. |
114 static const char alphaNumericEncodingMap[64] = { | 115 static const char alphaNumericEncodingMap[64] = { |
115 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, | 116 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, |
116 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, | 117 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, |
117 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, | 118 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, |
118 0x59, 0x5A, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, | 119 0x59, 0x5A, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, |
119 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, | 120 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, |
120 0x6F, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, | 121 0x6F, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
217 } else if (c == '\n' || (c == '\r' && (i + 1 >= length || string.data()[ i + 1] != '\n'))) { | 218 } else if (c == '\n' || (c == '\r' && (i + 1 >= length || string.data()[ i + 1] != '\n'))) { |
218 append(buffer, "%0D%0A"); | 219 append(buffer, "%0D%0A"); |
219 } else if (c != '\r') { | 220 } else if (c != '\r') { |
220 append(buffer, '%'); | 221 append(buffer, '%'); |
221 appendByteAsHex(c, buffer); | 222 appendByteAsHex(c, buffer); |
222 } | 223 } |
223 } | 224 } |
224 } | 225 } |
225 | 226 |
226 } | 227 } |
OLD | NEW |