summaryrefslogtreecommitdiff
path: root/lib/escape.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2000-08-31 12:03:04 +0000
committerDaniel Stenberg <daniel@haxx.se>2000-08-31 12:03:04 +0000
commit60eab89f10319fed1b5c6174a301b25f514c72b1 (patch)
treef63d6199ff8c49d3fdf5265e2539eadb13c05cf7 /lib/escape.c
parent1cedcce3e93d7649c5c1db7ab69192b655f6d168 (diff)
downloadcurl-60eab89f10319fed1b5c6174a301b25f514c72b1.tar.gz
in unescape(), '+' is now only converted to space after the first '?'
Diffstat (limited to 'lib/escape.c')
-rw-r--r--lib/escape.c24
1 files changed, 17 insertions, 7 deletions
diff --git a/lib/escape.c b/lib/escape.c
index 0a8c5cf37..c728b80f8 100644
--- a/lib/escape.c
+++ b/lib/escape.c
@@ -41,6 +41,9 @@
/* Escape and unescape URL encoding in strings. The functions return a new
* allocated string or NULL if an error occurred. */
+#include "setup.h"
+#include <curl/curl.h>
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -88,17 +91,24 @@ char *curl_unescape(char *string, int length)
unsigned char in;
int index=0;
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) {
in = *string;
- if('+' == in)
- in = ' ';
+ if(querypart && ('+' == in))
+ in = ' ';
+ else if(!querypart && ('?' == in)) {
+ /* we have "walked in" to the query part */
+ querypart=TRUE;
+ }
else if('%' == in) {
- /* encoded part */
- if(sscanf(string+1, "%02X", &hex)) {
- in = hex;
- string+=2;
- }
+ /* encoded part */
+ if(sscanf(string+1, "%02X", &hex)) {
+ in = hex;
+ string+=2;
+ }
}
ns[index++] = in;