else {
/* encode it */
unsigned char out[3]={'%'};
- Curl_hexbyte(&out[1], in, FALSE);
+ Curl_hexbyte(&out[1], in);
if(curlx_dyn_addn(&d, out, 3))
return NULL;
}
DEBUGASSERT(src && len && (olen >= 3));
if(src && len && (olen >= 3)) {
while(len-- && (olen >= 3)) {
- Curl_hexbyte(out, *src, TRUE);
+ out[0] = Curl_ldigits[*src >> 4];
+ out[1] = Curl_ldigits[*src & 0x0F];
++src;
out += 2;
olen -= 2;
/* Curl_hexbyte
*
- * Output a single unsigned char as a two-digit hex number, lowercase or
- * uppercase
+ * Output a single unsigned char as a two-digit UPPERCASE hex number.
*/
void Curl_hexbyte(unsigned char *dest, /* must fit two bytes */
- unsigned char val,
- bool lowercase)
+ unsigned char val)
{
- const unsigned char *t = lowercase ? Curl_ldigits : Curl_udigits;
- dest[0] = t[val >> 4];
- dest[1] = t[val & 0x0F];
+ dest[0] = Curl_udigits[val >> 4];
+ dest[1] = Curl_udigits[val & 0x0F];
}
{"https://"
"%e2%84%82%e1%b5%a4%e2%93%87%e2%84%92%e3%80%82%f0%9d%90%92%f0%9f%84%b4",
"https | [11] | [12] | [13] | "
- "%e2%84%82%e1%b5%a4%e2%93%87%e2%84%92%e3%80%82%f0%9d%90%92%f0%9f%84%b4 "
+ "%E2%84%82%E1%B5%A4%E2%93%87%E2%84%92%E3%80%82%F0%9D%90%92%F0%9F%84%B4 "
"| [15] | / | [16] | [17]",
0, CURLU_URLENCODE, CURLUE_OK},
{"https://"
"\xe2\x84\x82\xe1\xb5\xa4\xe2\x93\x87\xe2\x84\x92"
"\xe3\x80\x82\xf0\x9d\x90\x92\xf0\x9f\x84\xb4",
"https | [11] | [12] | [13] | "
- "%e2%84%82%e1%b5%a4%e2%93%87%e2%84%92%e3%80%82%f0%9d%90%92%f0%9f%84%b4 "
+ "%E2%84%82%E1%B5%A4%E2%93%87%E2%84%92%E3%80%82%F0%9D%90%92%F0%9F%84%B4 "
"| [15] | / | [16] | [17]",
0, CURLU_URLENCODE, CURLUE_OK},
{"https://user@example.net?he l lo",
{"http://example.com%2F127.0.0.1/", "", 0, 0, CURLUE_BAD_HOSTNAME},
{"https://%41", "https://A/", 0, 0, CURLUE_OK},
{"https://%20", "", 0, 0, CURLUE_BAD_HOSTNAME},
- {"https://%41%0d", "", 0, 0, CURLUE_BAD_HOSTNAME},
+ {"https://%41%0D", "", 0, 0, CURLUE_BAD_HOSTNAME},
{"https://%25", "", 0, 0, CURLUE_BAD_HOSTNAME},
{"https://_%c0_", "https://_\xC0_/", 0, 0, CURLUE_OK},
{"https://_%c0_", "https://_%C0_/", 0, CURLU_URLENCODE, CURLUE_OK},
0, 0, CURLUE_OK, CURLUE_OK},
{"https://example.com/",
"path=one\ntwo,",
- "https://example.com/one%0atwo",
+ "https://example.com/one%0Atwo",
0, CURLU_URLENCODE, CURLUE_OK, CURLUE_OK},
{"https://example.com/",
"path=one\rtwo,",
- "https://example.com/one%0dtwo",
+ "https://example.com/one%0Dtwo",
0, CURLU_URLENCODE, CURLUE_OK, CURLUE_OK},
{"https://example.com/",
"host=%43url.se,",
{"https://example.com/",
"query=Al2cO3tDkcDZ3EWE5Lh+LX8TPHs,", /* contains '+' */
- "https://example.com/?Al2cO3tDkcDZ3EWE5Lh%2bLX8TPHs",
+ "https://example.com/?Al2cO3tDkcDZ3EWE5Lh%2BLX8TPHs",
CURLU_URLDECODE, /* decode on get */
CURLU_URLENCODE, /* encode on set */
CURLUE_OK, CURLUE_OK},
0, 0, CURLUE_OK, CURLUE_OK},
{NULL,
"scheme=https,user= @:,host=foobar,",
- "https://%20%20%20%40%3a@foobar/",
+ "https://%20%20%20%40%3A@foobar/",
0, CURLU_URLENCODE, CURLUE_OK, CURLUE_OK},
/* Setting a host name with spaces is not OK: */
{NULL,
0, CURLU_URLENCODE, CURLUE_OK, CURLUE_OK},
{NULL,
"scheme=https,host=foobar,path=\xc3\xa4\xc3\xb6\xc3\xbc,",
- "https://foobar/%c3%a4%c3%b6%c3%bc",
+ "https://foobar/%C3%A4%C3%B6%C3%BC",
0, CURLU_URLENCODE, CURLUE_OK, CURLUE_OK},
{"imap://user:secret;opt@host/",
"options=updated,scheme=imaps,password=p4ssw0rd,",
static const struct querycase append_list[] = {
{"HTTP://test/?s", "name=joe\x02", "http://test/?s&name=joe%02",
0, CURLU_URLENCODE, CURLUE_OK},
- {"HTTP://test/?size=2#f", "name=joe=", "http://test/?size=2&name=joe%3d#f",
+ {"HTTP://test/?size=2#f", "name=joe=", "http://test/?size=2&name=joe%3D#f",
0, CURLU_URLENCODE, CURLUE_OK},
{"HTTP://test/?size=2#f", "name=joe doe",
"http://test/?size=2&name=joe+doe#f",