diff --git a/tests/Makefile.am b/tests/Makefile.am index fb134d40..5ee5f5bc 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -66,6 +66,9 @@ kkdcp_parsing_LDADD = ../gl/libgnu.a $(LIBTALLOC_LIBS) ../src/ccan/libccan.a json_escape_SOURCES = json-escape.c json_escape_LDADD = ../gl/libgnu.a $(LIBTALLOC_LIBS) ../src/ccan/libccan.a +url_escape_SOURCES = url-escape.c +url_escape_LDADD = ../gl/libgnu.a $(LIBTALLOC_LIBS) ../src/ccan/libccan.a + ipv4_prefix_SOURCES = ipv4-prefix.c ipv4_prefix_LDADD = ../gl/libgnu.a $(LIBTALLOC_LIBS) ../src/ccan/libccan.a @@ -91,7 +94,7 @@ valid_hostname_LDADD = ../gl/libgnu.a port_parsing_LDADD = ../gl/libgnu.a $(LIBTALLOC_LIBS) ../src/ccan/libccan.a check_PROGRAMS = str-test str-test2 ipv4-prefix ipv6-prefix kkdcp-parsing json-escape ban-ips \ - port-parsing human_addr valid-hostname + port-parsing human_addr valid-hostname url-escape TESTS = $(dist_check_SCRIPTS) $(check_PROGRAMS) diff --git a/tests/url-escape.c b/tests/url-escape.c new file mode 100644 index 00000000..85200d9e --- /dev/null +++ b/tests/url-escape.c @@ -0,0 +1,65 @@ +/* + * 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%20Beach", + "%20", + "Laguna%25%2B%40Beach" +}; + +static char *decoded_strings[] = +{ + "Laguna Beach", + " ", + "Laguna%+@Beach" +}; + +int main() +{ + char *dec, *url; + unsigned i; + unsigned len; + + for (i=0;i