codec/url.c: Always encode whitespace characters.
authorMark Wooding <mdw@distorted.org.uk>
Sat, 26 May 2018 22:31:00 +0000 (23:31 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Sat, 26 May 2018 23:03:46 +0000 (00:03 +0100)
Vertical whitespace is obviously bad, so this is a longstanding bug; but
all whitespace should really be escaped.

codec/url.c

index f502f7c..4e7f190 100644 (file)
@@ -67,7 +67,8 @@ static void encode(url_ectx *ctx, dstr *d, const char *p)
        DPUTC(d, '+');
        break;
       default:
-       if ((ctx->f & URLF_LAX) || isalnum((unsigned char)*p))
+       if (!isspace((unsigned char)*p) &&
+           ((ctx->f & URLF_LAX) || isalnum((unsigned char)*p)))
          goto safe;
        else
          goto unsafe;