ignore '+' in URLs, generate only %-codes
This commit is contained in:
parent
2443e1f38c
commit
2f8e7f56b3
15
lib/escape.c
15
lib/escape.c
@ -48,9 +48,7 @@ char *curl_escape(const char *string, int length)
|
|||||||
length = alloc-1;
|
length = alloc-1;
|
||||||
while(length--) {
|
while(length--) {
|
||||||
in = *string;
|
in = *string;
|
||||||
if(' ' == in)
|
if(!(in >= 'a' && in <= 'z') &&
|
||||||
ns[index++] = '+';
|
|
||||||
else if(!(in >= 'a' && in <= 'z') &&
|
|
||||||
!(in >= 'A' && in <= 'Z') &&
|
!(in >= 'A' && in <= 'Z') &&
|
||||||
!(in >= '0' && in <= '9')) {
|
!(in >= '0' && in <= '9')) {
|
||||||
/* encode it */
|
/* encode it */
|
||||||
@ -82,19 +80,10 @@ char *curl_unescape(const char *string, int length)
|
|||||||
unsigned char in;
|
unsigned char in;
|
||||||
int index=0;
|
int index=0;
|
||||||
unsigned int hex;
|
unsigned int hex;
|
||||||
char querypart=FALSE; /* everything to the right of a '?' letter is
|
|
||||||
the "query part" where '+' should become ' '.
|
|
||||||
RFC 2316, section 3.10 */
|
|
||||||
|
|
||||||
while(--alloc > 0) {
|
while(--alloc > 0) {
|
||||||
in = *string;
|
in = *string;
|
||||||
if(querypart && ('+' == in))
|
if('%' == in) {
|
||||||
in = ' ';
|
|
||||||
else if(!querypart && ('?' == in)) {
|
|
||||||
/* we have "walked in" to the query part */
|
|
||||||
querypart=TRUE;
|
|
||||||
}
|
|
||||||
else if('%' == in) {
|
|
||||||
/* encoded part */
|
/* encoded part */
|
||||||
if(sscanf(string+1, "%02X", &hex)) {
|
if(sscanf(string+1, "%02X", &hex)) {
|
||||||
in = hex;
|
in = hex;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user