mirror of
https://github.com/moparisthebest/curl
synced 2024-12-22 08:08:50 -05:00
in unescape(), '+' is now only converted to space after the first '?'
This commit is contained in:
parent
1cedcce3e9
commit
60eab89f10
24
lib/escape.c
24
lib/escape.c
@ -41,6 +41,9 @@
|
|||||||
/* Escape and unescape URL encoding in strings. The functions return a new
|
/* Escape and unescape URL encoding in strings. The functions return a new
|
||||||
* allocated string or NULL if an error occurred. */
|
* allocated string or NULL if an error occurred. */
|
||||||
|
|
||||||
|
#include "setup.h"
|
||||||
|
#include <curl/curl.h>
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@ -88,17 +91,24 @@ char *curl_unescape(char *string, int length)
|
|||||||
unsigned char in;
|
unsigned char in;
|
||||||
int index=0;
|
int index=0;
|
||||||
int hex;
|
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) {
|
while(--alloc) {
|
||||||
in = *string;
|
in = *string;
|
||||||
if('+' == in)
|
if(querypart && ('+' == in))
|
||||||
in = ' ';
|
in = ' ';
|
||||||
|
else if(!querypart && ('?' == in)) {
|
||||||
|
/* we have "walked in" to the query part */
|
||||||
|
querypart=TRUE;
|
||||||
|
}
|
||||||
else if('%' == in) {
|
else if('%' == in) {
|
||||||
/* encoded part */
|
/* encoded part */
|
||||||
if(sscanf(string+1, "%02X", &hex)) {
|
if(sscanf(string+1, "%02X", &hex)) {
|
||||||
in = hex;
|
in = hex;
|
||||||
string+=2;
|
string+=2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ns[index++] = in;
|
ns[index++] = in;
|
||||||
|
Loading…
Reference in New Issue
Block a user