If the redirect URL contains characters RFC 3986 doesn't permit, encode them
authorFabian Keil <fk@fabiankeil.de>
Sun, 6 Nov 2011 11:45:28 +0000 (11:45 +0000)
committerFabian Keil <fk@fabiankeil.de>
Sun, 6 Nov 2011 11:45:28 +0000 (11:45 +0000)
filters.c

index e2f490c..3994638 100644 (file)
--- a/filters.c
+++ b/filters.c
@@ -1,4 +1,4 @@
-const char filters_rcs[] = "$Id: filters.c,v 1.154 2011/10/30 16:22:46 fabiankeil Exp $";
+const char filters_rcs[] = "$Id: filters.c,v 1.155 2011/11/06 11:36:42 fabiankeil Exp $";
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/filters.c,v $
@@ -1308,6 +1308,20 @@ struct http_response *redirect_url(struct client_state *csp)
    /* Did any redirect action trigger? */
    if (new_url)
    {
+      if (url_requires_percent_encoding(new_url))
+      {
+         char *encoded_url;
+         log_error(LOG_LEVEL_REDIRECTS, "Percent-encoding redirect URL: %N",
+            strlen(new_url), new_url);
+         encoded_url = percent_encode_url(new_url);
+         freez(new_url);
+         if (encoded_url == NULL)
+         {
+            return cgi_error_memory();
+         }
+         new_url = encoded_url;
+      }
+
       if (0 == strcmpic(new_url, csp->http->url))
       {
          log_error(LOG_LEVEL_ERROR,