]> mj.ucw.cz Git - libucw.git/blobdiff - ucw/url.c
Logging: Precise timestamps and syslog PID flag are now configurable.
[libucw.git] / ucw / url.c
index 50ed2f7ecd03d840728472d153053b47ab6cdf91..39e52946e2bd086cd3cbdaefa4985fe217b56fde 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,15 +139,18 @@ 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
        {
-         uns val = ((byte)*s < NCC_MAX) ? NCC_CHARS[(byte)*s] : *s;
+         uns val = (byte)(((byte)*s < NCC_MAX) ? NCC_CHARS[(byte)*s] : *s);
          *d++ = '%';
          *d++ = enhex(val >> 4);
          *d++ = enhex(val & 0x0f);
@@ -165,14 +170,14 @@ url_enescape_friendly(const char *src, char *dest)
     {
       if (dest >= end)
        return URL_ERR_TOO_LONG;
-      if (*srcb < NCC_MAX)
+      if ((byte)*srcb < NCC_MAX)
        *dest++ = NCC_CHARS[*srcb++];
       else if (*srcb >= 0x20 && *srcb < 0x7f)
        *dest++ = *srcb++;
       else
        {
          *dest++ = '%';
-         *dest++ = enhex(*srcb >> 4);
+         *dest++ = enhex((byte)*srcb >> 4);
          *dest++ = enhex(*srcb++ & 0x0f);
        }
     }