]> mj.ucw.cz Git - libucw.git/commitdiff
Add flag to use old URL encoding
authorMichal Vaner <vorner@ucw.cz>
Fri, 7 Nov 2008 13:33:59 +0000 (14:33 +0100)
committerMichal Vaner <vorner@ucw.cz>
Fri, 7 Nov 2008 13:43:23 +0000 (14:43 +0100)
The new encoding is not compatible with already running sherlock
installation. Adds a CONFIG_URL_ESCAPE_COMPAT compile switch to keep the
old behaviour.

ucw/url.c
ucw/url.h

index 50ed2f7ecd03d840728472d153053b47ab6cdf91..4b0ddeaa0be11ee6a9b8d7ddf8269f5922e07ae1 100644 (file)
--- a/ucw/url.c
+++ b/ucw/url.c
@@ -92,12 +92,14 @@ url_deescape(const char *s, char *d)
              val = NCC_AND; break;
            case '#':
              val = NCC_HASH; break;
+#ifndef CONFIG_URL_ESCAPE_COMPAT
            case '$':
              val = NCC_DOLLAR; break;
            case '+':
              val = NCC_PLUS; break;
            case ',':
              val = NCC_COMMA; break;
+#endif
            }
          *d++ = val;
          s += 3;
@@ -137,11 +139,14 @@ url_enescape(const char *s, char *d)
       if (d >= end)
        return URL_ERR_TOO_LONG;
       if (Calnum(c) ||                                                 /* RFC 2396 (2.1-2.3): Only alphanumerics ... */
-         c == '-' || c == '_' || c == '.' || c == '+' || c == '~' ||   /* ... and several other exceptions ... */
-         c == '!' || c == '*' || c == '\'' || c == '(' || c == ')' ||
-         c == '/' || c == '?' || c == ':' || c == '@' ||               /* ... and reserved chars used for reserved purpose */
-         c == '=' || c == '&' || c == '#' || c == ';' ||
-         c == '$' || c == '+' || c == ',')
+         c == '!' || c == '*' || c == '\'' || c == '(' || c == ')' ||  /* ... and some exceptions and reserved chars */
+         c == '$' || c == '-' || c == '_' || c == '.' || c == '+' ||
+         c == ',' || c == '=' || c == '&' || c == '#' || c == ';' ||
+         c == '/' || c == '?' || c == ':' || c == '@'
+#ifndef CONFIG_URL_ESCAPE_COMPAT
+         || c == '~'
+#endif
+       )
        *d++ = *s++;
       else
        {
index d2689be536d8bd4b272bded3b756d1e2b93a0333..c389fb16a9a9b72b8acc0e16a34307b6c7a4a04e 100644 (file)
--- a/ucw/url.h
+++ b/ucw/url.h
@@ -24,15 +24,23 @@ enum {
   NCC_EQUAL = 6,
   NCC_AND = 7,
   NCC_HASH = 8,
+#ifdef CONFIG_URL_ESCAPE_COMPAT
+  NCC_MAX = 9
+#else
   // Avoid 9 (\t) and 10 (\n)
   NCC_DOLLAR = 11,
   NCC_PLUS = 12,
   // Avoid 13 (\r)
   NCC_COMMA = 14,
   NCC_MAX = 15
+#endif
 };
 
+#ifdef CONFIG_URL_ESCAPE_COMPAT
+#define NCC_CHARS " ;/?:@=&#"
+#else
 #define NCC_CHARS " ;/?:@=&#\t\n$+\r,"
+#endif
 
 /* Remove/Introduce '%' escapes */