fraglen = strlen(fragment);
if(fraglen > 1) {
/* skip the leading '#' in the copy but include the terminating null */
- u->fragment = Curl_memdup(fragment + 1, fraglen);
- if(!u->fragment) {
- result = CURLUE_OUT_OF_MEMORY;
- goto fail;
+ if(flags & CURLU_URLENCODE) {
+ struct dynbuf enc;
+ Curl_dyn_init(&enc, CURL_MAX_INPUT_LENGTH);
+ if(urlencode_str(&enc, fragment + 1, fraglen, TRUE, FALSE)) {
+ result = CURLUE_OUT_OF_MEMORY;
+ goto fail;
+ }
+ u->fragment = Curl_dyn_ptr(&enc);
}
+ else {
+ u->fragment = Curl_memdup(fragment + 1, fraglen);
+ if(!u->fragment) {
+ result = CURLUE_OUT_OF_MEMORY;
+ goto fail;
+ }
- if(junkscan(u->fragment, flags)) {
- result = CURLUE_BAD_FRAGMENT;
- goto fail;
+ if(junkscan(u->fragment, flags)) {
+ result = CURLUE_BAD_FRAGMENT;
+ goto fail;
+ }
}
}
}
};
static const struct testcase get_parts_list[] ={
+ {"https://user@example.net?hello# space ",
+ "https | user | [12] | [13] | example.net | [15] | / | hello | %20space%20",
+ CURLU_ALLOW_SPACE|CURLU_URLENCODE, 0, CURLUE_OK},
{"https://test%test", "", 0, 0, CURLUE_BAD_HOSTNAME},
{"https://example.com%252f%40@example.net",
"https | example.com%2f@ | [12] | [13] | example.net | [15] | / "