From 3279ca84f843882f20522565acf105e1a3a9e2f8 Mon Sep 17 00:00:00 2001 From: leitner Date: Mon, 29 Sep 2003 01:12:36 +0000 Subject: [PATCH] don't use black list for urlencoding, use white list. --- textcode/fmt_urlencoded.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/textcode/fmt_urlencoded.c b/textcode/fmt_urlencoded.c index 4bf56bc..8f2dcd8 100644 --- a/textcode/fmt_urlencoded.c +++ b/textcode/fmt_urlencoded.c @@ -3,12 +3,19 @@ #include "str.h" #include "haveinline.h" +static inline int issafe(unsigned char c) { + const char safe[] = "$/.=~"; + return ((c>='A' && c<='Z') || + (c>='a' && c<='z') || + (c>='0' && c<='9') || + safe[str_chr(safe,c)]); +} + unsigned long fmt_urlencoded(char* dest,const char* src,unsigned long len) { - const char unsafe[]=" +%<>\"#{}|\\^~[]`;/?:@=&"; register const unsigned char* s=(const unsigned char*) src; unsigned long written=0,i; for (i=0; i>4);