Update ctors to use new attribute shortcuts.
[shibboleth/cpp-xmltooling.git] / xmltooling / util / URLEncoder.cpp
index d646251..0196f2b 100644 (file)
@@ -37,13 +37,21 @@ static char x2c(char *what)
     return(digit);
 }
 
+URLEncoder::URLEncoder()
+{
+}
+
+URLEncoder::~URLEncoder()
+{
+}
+
 void URLEncoder::decode(char* s) const
 {
     register int x,y;
 
     for(x=0,y=0;s[y];++x,++y)
     {
-        if((s[x] = s[y]) == '%' && s[y+1] && s[y+2])
+        if((s[x] = s[y]) == '%' && isxdigit(s[y+1]) && isxdigit(s[y+2]))
         {
             s[x] = x2c(&s[y+1]);
             y+=2;
@@ -75,3 +83,9 @@ string URLEncoder::encode(const char* s) const
     }
     return ret;
 }
+
+bool URLEncoder::isBad(char ch) const
+{
+    static char badchars[]="=&/?:\"\\+<>#%{}|^~[],`;@";
+    return (ch<=0x20 || ch>=0x7F || strchr(badchars,ch));
+}