mirror of
https://github.com/curl/curl.git
synced 2026-07-25 13:47:23 +03:00
curl_escape() no longer attempts to detect already encoded stuff (in order
not to re-encode it).
This commit is contained in:
parent
47bb09e908
commit
2827f5327a
1 changed files with 7 additions and 20 deletions
27
lib/escape.c
27
lib/escape.c
|
|
@ -54,28 +54,15 @@ char *curl_escape(char *string, int length)
|
|||
!(in >= 'A' && in <= 'Z') &&
|
||||
!(in >= '0' && in <= '9')) {
|
||||
/* encode it */
|
||||
if(('%' == in) &&
|
||||
(length>=2) &&
|
||||
isxdigit((int)string[1]) &&
|
||||
isxdigit((int)string[2]) ) {
|
||||
/*
|
||||
* This is an already encoded letter, leave it!
|
||||
*/
|
||||
memcpy(&ns[index], string, 3);
|
||||
string+=2;
|
||||
newlen += 2; /* the size grows with two, since this'll become a %XX */
|
||||
if(newlen > alloc) {
|
||||
alloc *= 2;
|
||||
ns = realloc(ns, alloc);
|
||||
if(!ns)
|
||||
return NULL;
|
||||
}
|
||||
else {
|
||||
/* encode this now */
|
||||
sprintf(&ns[index], "%%%02X", in);
|
||||
|
||||
newlen += 2; /* the size grows with two, since this'll become a %XX */
|
||||
if(newlen > alloc) {
|
||||
alloc *= 2;
|
||||
ns = realloc(ns, alloc);
|
||||
if(!ns)
|
||||
return NULL;
|
||||
}
|
||||
sprintf(&ns[index], "%%%02X", in);
|
||||
}
|
||||
index+=3;
|
||||
}
|
||||
else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue