mirror of
https://gitlab.com/openconnect/ocserv.git
synced 2026-02-10 08:46:58 +08:00
Make escape_url() percent-escape fewer characters and escape ' ' as '+'
Per RFC 3986, neither ASCII alphanumeric characters, nor any of '-', '_', '.', '~', need to be escaped anywhere in a URL or query string.
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
|
||||
@@ -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"
|
||||
};
|
||||
|
||||
|
||||
@@ -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 <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