diff --git a/src/html.c b/src/html.c
index 75481ef9..567704fa 100644
--- a/src/html.c
+++ b/src/html.c
@@ -164,8 +164,11 @@ char *escape_url(void *pool, const char *url, unsigned len, unsigned *out_len)
return NULL;
for (i = pos = 0; i < len;) {
- if (c_isalpha(url[i])) {
+ if (c_isalnum(url[i]) || url[i]=='-' || url[i]=='_' || url[i]=='.' || url[i]=='~') {
msg[pos++] = url[i++];
+ } else if (url[i] == ' ') {
+ msg[pos++] = '+';
+ i++;
} else {
snprintf(&msg[pos], 4, "%%%02X", (unsigned)url[i++]);
pos+=3;
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 534c495a..4636391c 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -87,9 +87,6 @@ json_escape_LDADD = $(LDADD)
url_escape_SOURCES = url-escape.c
url_escape_LDADD = $(LDADD)
-url_unescape_SOURCES = url-escape.c
-url_unescape_LDADD = $(LDADD)
-
html_escape_SOURCES = html-escape.c
html_escape_LDADD = $(LDADD)
@@ -118,7 +115,7 @@ valid_hostname_LDADD = $(LDADD)
port_parsing_LDADD = $(LDADD)
check_PROGRAMS = str-test str-test2 ipv4-prefix ipv6-prefix kkdcp-parsing json-escape ban-ips \
- port-parsing human_addr valid-hostname url-escape url-unescape html-escape cstp-recv \
+ port-parsing human_addr valid-hostname url-escape html-escape cstp-recv \
proxyproto-v1
diff --git a/tests/url-escape.c b/tests/url-escape.c
index 85200d9e..ca9cc0a4 100644
--- a/tests/url-escape.c
+++ b/tests/url-escape.c
@@ -28,15 +28,15 @@
static char *strings[] =
{
- "Laguna%20Beach",
- "%20",
+ "Laguna+Beach",
+ "_+-.~%2C",
"Laguna%25%2B%40Beach"
};
static char *decoded_strings[] =
{
"Laguna Beach",
- " ",
+ "_ -.~,",
"Laguna%+@Beach"
};
diff --git a/tests/url-unescape.c b/tests/url-unescape.c
deleted file mode 100644
index 5d933598..00000000
--- a/tests/url-unescape.c
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (C) 2016 Nikos Mavrogiannopoulos
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-#include
-#include
-#include
-#include
-
-#include
-#include
-#include
-#include "../src/html.h"
-#include "../src/html.c"
-
-static char *strings[] =
-{
- "Laguna+Beach",
-};
-
-static char *decoded_strings[] =
-{
- "Laguna Beach",
-};
-
-int main()
-{
- char *dec;
- unsigned i;
- unsigned len;
-
- for (i=0;i