From 1d84a7baefeba108a474b628a4dc13ca707bac15 Mon Sep 17 00:00:00 2001 From: Daniel Lenski Date: Sun, 16 Oct 2016 12:37:58 -0700 Subject: [PATCH] Make buf_append_urlencoded() percent-encode fewer characters. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Per RFC 3986, the characters '-', '_', '.', '~' don't need to be percent-encoded anywhere in a URL or query string. Removed special case for ' ' → '+' to prevent incompatibility with ocserv: http://lists.infradead.org/pipermail/openconnect-devel/2016-October/004042.html /* else if (c==' ') buf_append_bytes(buf, "+", 1); */ Signed-off-by: Dan Lenski Signed-off-by: David Woodhouse --- http.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/http.c b/http.c index 28bac5aa..6166bb3a 100644 --- a/http.c +++ b/http.c @@ -45,7 +45,7 @@ void buf_append_urlencoded(struct oc_text_buf *buf, const char *str) { while (str && *str) { unsigned char c = *str; - if (c < 0x80 && isalnum((int)(c))) + if (c < 0x80 && (isalnum((int)(c)) || c=='-' || c=='_' || c=='.' || c=='~')) buf_append_bytes(buf, str, 1); else buf_append(buf, "%%%02x", c);