1
0
Fork 0
mirror of https://github.com/warmcat/libwebsockets.git synced 2025-03-09 00:00:04 +01:00

uriencoding deal with0uriencoded question mark properly

Signed-off-by: Andy Green <andy.green@linaro.org>
This commit is contained in:
Andy Green 2015-12-14 19:42:26 +08:00
parent ab4a94dd46
commit 38f3225b22
2 changed files with 11 additions and 2 deletions

View file

@ -216,7 +216,7 @@ int lws_parse(struct lws_context *context, struct lws *wsi, unsigned char c)
WSI_TOKEN_PATCH_URI,
WSI_TOKEN_DELETE_URI,
};
unsigned int n, m;
unsigned int n, m, enc = 0;
switch (wsi->u.hdr.parser_state) {
default:
@ -286,6 +286,7 @@ int lws_parse(struct lws_context *context, struct lws *wsi, unsigned char c)
}
c = (char_to_hex(wsi->u.hdr.esc_stash) << 4) |
char_to_hex(c);
enc = 1;
wsi->u.hdr.ues = URIES_IDLE;
break;
}
@ -360,7 +361,7 @@ int lws_parse(struct lws_context *context, struct lws *wsi, unsigned char c)
break;
}
if (c == '?') { /* start of URI arguments */
if (c == '?' && !enc) { /* start of URI arguments */
/* seal off uri header */
wsi->u.hdr.ah->data[wsi->u.hdr.ah->pos++] = '\0';

View file

@ -56,6 +56,14 @@ while [ -z "`grep Listening $LOG`" ] ; do
done
check
echo
echo "---- /cgi-bin/settingsjs?UPDATE_SETTINGS=1&Root_Channels_1_Channel_name_http_post=%3F&Root_Channels_1_Channel_location_http_post=%3F"
rm -f /tmp/lwscap
echo -e "GET /cgi-bin/settingsjs?UPDATE_SETTINGS=1&Root_Channels_1_Channel_name_http_post=%3F&Root_Channels_1_Channel_location_http_post=%3F HTTP/1.1\x0d\x0a\x0d\x0a" | nc $SERVER $PORT | sed '1,/^\r$/d'> /tmp/lwscap
check args "UPDATE_SETTINGS=1&Root_Channels_1_Channel_name_http_post=?&Root_Channels_1_Channel_location_http_post=?"
echo
echo "---- ? processing (%2f%2e%2e%2f%2e./test.html?arg=1)"
rm -f /tmp/lwscap