>From ca8aab7ac68c0d58ab7e7ac736cf6d7d21e80b67 Mon Sep 17 00:00:00 2001
From: Markus Linnala <Markus.Linnala@cybercom.com>
Date: Mon, 7 Nov 2011 20:49:15 +0200
Subject: [PATCH] application/x-www-form-urlencoded compatible mode

Unescape '+' to ' '. Needed, if encoding is application/x-www-form-urlencoded compatible.
---
 src/core/ngx_string.c |    7 +++++++
 src/core/ngx_string.h |    1 +
 2 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/src/core/ngx_string.c b/src/core/ngx_string.c
index 29f8e0d..39add87 100644
--- a/src/core/ngx_string.c
+++ b/src/core/ngx_string.c
@@ -1536,6 +1536,13 @@ ngx_unescape_uri(u_char **dst, u_char **src, size_t size, ngx_uint_t type)
                 break;
             }
 
+            if (ch == '+'
+                && (type & (NGX_UNESCAPE_FORM_URL)))
+            {
+                *d++ = ' ';
+                break;
+            }
+
             *d++ = ch;
             break;
 
diff --git a/src/core/ngx_string.h b/src/core/ngx_string.h
index 2b9c59a..6158c40 100644
--- a/src/core/ngx_string.h
+++ b/src/core/ngx_string.h
@@ -199,6 +199,7 @@ u_char *ngx_utf8_cpystrn(u_char *dst, u_char *src, size_t n, size_t len);
 
 #define NGX_UNESCAPE_URI       1
 #define NGX_UNESCAPE_REDIRECT  2
+#define NGX_UNESCAPE_FORM_URL  4
 
 uintptr_t ngx_escape_uri(u_char *dst, u_char *src, size_t size,
     ngx_uint_t type);
-- 
1.7.6.4


