From 7cc97d98213436350624bcf5c38203b3116ca651 Mon Sep 17 00:00:00 2001 From: Richard Walters Date: Thu, 28 Mar 2019 00:00:15 -0700 Subject: Percent-encode '+' in the query portion --- src/Uri.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/Uri.cpp b/src/Uri.cpp index b6b82e1..fef7fb6 100644 --- a/src/Uri.cpp +++ b/src/Uri.cpp @@ -98,6 +98,21 @@ namespace { '/', '?' }; + /** + * This is the character set almost corresponds to the "query" syntax + * specified in RFC 3986 (https://tools.ietf.org/html/rfc3986), + * leaving out "pct-encoded", except that '+' is also excluded, because + * for some web services (e.g. AWS S3) a '+' is treated as + * synonymous with a space (' ') and thus gets misinterpreted. + */ + const Uri::CharacterSet QUERY_NOT_PCT_ENCODED_WITHOUT_PLUS{ + UNRESERVED, + '!', '$', '&', '\'', '(', ')', + '*', ',', ';', '=', + ':', '@', + '/', '?' + }; + /** * This is the character set corresponds to the "userinfo" syntax * specified in RFC 3986 (https://tools.ietf.org/html/rfc3986), @@ -1450,7 +1465,7 @@ namespace Uri { ++i; } if (impl_->hasQuery) { - buffer << '?' << EncodeElement(impl_->query, QUERY_OR_FRAGMENT_NOT_PCT_ENCODED); + buffer << '?' << EncodeElement(impl_->query, QUERY_NOT_PCT_ENCODED_WITHOUT_PLUS); } if (impl_->hasFragment) { buffer << '#' << EncodeElement(impl_->fragment, QUERY_OR_FRAGMENT_NOT_PCT_ENCODED); -- cgit v1.2.3