mirror of
https://gitlab.com/openconnect/ocserv.git
synced 2026-02-10 00:37:00 +08:00
tests for unescaping decimal HTML escapes and '+' in URLs
This commit is contained in:
@@ -87,6 +87,9 @@ json_escape_LDADD = $(LDADD)
|
|||||||
url_escape_SOURCES = url-escape.c
|
url_escape_SOURCES = url-escape.c
|
||||||
url_escape_LDADD = $(LDADD)
|
url_escape_LDADD = $(LDADD)
|
||||||
|
|
||||||
|
url_unescape_SOURCES = url-escape.c
|
||||||
|
url_unescape_LDADD = $(LDADD)
|
||||||
|
|
||||||
html_escape_SOURCES = html-escape.c
|
html_escape_SOURCES = html-escape.c
|
||||||
html_escape_LDADD = $(LDADD)
|
html_escape_LDADD = $(LDADD)
|
||||||
|
|
||||||
@@ -115,7 +118,7 @@ valid_hostname_LDADD = $(LDADD)
|
|||||||
port_parsing_LDADD = $(LDADD)
|
port_parsing_LDADD = $(LDADD)
|
||||||
|
|
||||||
check_PROGRAMS = str-test str-test2 ipv4-prefix ipv6-prefix kkdcp-parsing json-escape ban-ips \
|
check_PROGRAMS = str-test str-test2 ipv4-prefix ipv6-prefix kkdcp-parsing json-escape ban-ips \
|
||||||
port-parsing human_addr valid-hostname url-escape html-escape cstp-recv \
|
port-parsing human_addr valid-hostname url-escape url-unescape html-escape cstp-recv \
|
||||||
proxyproto-v1
|
proxyproto-v1
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -35,7 +35,9 @@ static char *strings[] =
|
|||||||
"try to escape \\escapes",
|
"try to escape \\escapes",
|
||||||
"\tbig pile \b\b of stuff\r\n",
|
"\tbig pile \b\b of stuff\r\n",
|
||||||
"<hi there>",
|
"<hi there>",
|
||||||
"\"hi there\""
|
"\"hi there\"",
|
||||||
|
"Ahoy matey!",
|
||||||
|
"Ahoy matey!"
|
||||||
};
|
};
|
||||||
|
|
||||||
static char *encoded_strings[] =
|
static char *encoded_strings[] =
|
||||||
@@ -47,7 +49,9 @@ static char *encoded_strings[] =
|
|||||||
"try to escape \\escapes",
|
"try to escape \\escapes",
|
||||||
"	big pile  of stuff
",
|
"	big pile  of stuff
",
|
||||||
"<hi there>",
|
"<hi there>",
|
||||||
""hi there""
|
""hi there"",
|
||||||
|
"Ahoy matey!",
|
||||||
|
"Ahoy matey!"
|
||||||
};
|
};
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
|
|||||||
54
tests/url-unescape.c
Normal file
54
tests/url-unescape.c
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
/*
|
||||||
|
* 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 <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <config.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
#include <netdb.h>
|
||||||
|
#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<sizeof(strings)/sizeof(strings[0]);i++) {
|
||||||
|
dec = unescape_url(NULL, strings[i], strlen(strings[i]), &len);
|
||||||
|
if (strcmp(dec, decoded_strings[i]) != 0) {
|
||||||
|
fprintf(stderr, "string %d, fails decoding:\n\tinput: '%s'\n\toutput: '%s'\n", i, decoded_strings[i], dec);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
talloc_free(dec);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user