summaryrefslogtreecommitdiff
path: root/lib/escape.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2010-09-28 23:46:14 +0200
committerDaniel Stenberg <daniel@haxx.se>2010-09-28 23:49:32 +0200
commit5df13c31735fa089d5344fde13b66ace1ea473d1 (patch)
tree783d6f38bfc41e3fdbc445e9c0ffe5f3cf90f0b6 /lib/escape.c
parented4eecc05e0cce36d8ce4ac9466376ca5fcfcba2 (diff)
downloadgnurl-5df13c31735fa089d5344fde13b66ace1ea473d1.tar.gz
gnurl-5df13c31735fa089d5344fde13b66ace1ea473d1.tar.bz2
gnurl-5df13c31735fa089d5344fde13b66ace1ea473d1.zip
curl_easy_escape: don't escape "unreserved" characters
According to RFC3986 section 2.3 the letters -, ., _ and ~ should not be percent-encoded. Reported by: Miguel Diaz Bug: http://curl.haxx.se/mail/lib-2010-09/0227.html
Diffstat (limited to 'lib/escape.c')
-rw-r--r--lib/escape.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/escape.c b/lib/escape.c
index 37d21e799..735e1d8a7 100644
--- a/lib/escape.c
+++ b/lib/escape.c
@@ -43,8 +43,10 @@
#include "memdebug.h"
/* Portable character check (remember EBCDIC). Do not use isalnum() because
-its behavior is altered by the current locale. */
-static bool Curl_isalnum(unsigned char in)
+ its behavior is altered by the current locale.
+ See http://tools.ietf.org/html/rfc3986#section-2.3
+*/
+static bool Curl_isunreserved(unsigned char in)
{
switch (in) {
case '0': case '1': case '2': case '3': case '4':
@@ -59,6 +61,7 @@ static bool Curl_isalnum(unsigned char in)
case 'K': case 'L': case 'M': case 'N': case 'O':
case 'P': case 'Q': case 'R': case 'S': case 'T':
case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z':
+ case '-': case '.': case '_': case '~':
return TRUE;
default:
break;
@@ -100,7 +103,7 @@ char *curl_easy_escape(CURL *handle, const char *string, int inlength)
while(length--) {
in = *string;
- if (Curl_isalnum(in)) {
+ if (Curl_isunreserved(in)) {
/* just copy this */
ns[strindex++]=in;
}