mirror of
https://github.com/moparisthebest/curl
synced 2024-08-13 17:03:50 -04:00
Jim Drash suggested and I made it not encode what looks like an already
encoded letter (in curl_escape)
This commit is contained in:
parent
546572da04
commit
58085dbbf6
15
lib/escape.c
15
lib/escape.c
@ -25,6 +25,7 @@
|
|||||||
* allocated string or NULL if an error occurred. */
|
* allocated string or NULL if an error occurred. */
|
||||||
|
|
||||||
#include "setup.h"
|
#include "setup.h"
|
||||||
|
#include <ctype.h>
|
||||||
#include <curl/curl.h>
|
#include <curl/curl.h>
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@ -52,6 +53,19 @@ char *curl_escape(char *string, int length)
|
|||||||
!(in >= 'A' && in <= 'Z') &&
|
!(in >= 'A' && in <= 'Z') &&
|
||||||
!(in >= '0' && in <= '9')) {
|
!(in >= '0' && in <= '9')) {
|
||||||
/* encode it */
|
/* 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;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
/* encode this now */
|
||||||
|
|
||||||
newlen += 2; /* the size grows with two, since this'll become a %XX */
|
newlen += 2; /* the size grows with two, since this'll become a %XX */
|
||||||
if(newlen > alloc) {
|
if(newlen > alloc) {
|
||||||
alloc *= 2;
|
alloc *= 2;
|
||||||
@ -60,6 +74,7 @@ char *curl_escape(char *string, int length)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
sprintf(&ns[index], "%%%02X", in);
|
sprintf(&ns[index], "%%%02X", in);
|
||||||
|
}
|
||||||
index+=3;
|
index+=3;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
Loading…
Reference in New Issue
Block a user