summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--scan_urlencoded_query.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/scan_urlencoded_query.c b/scan_urlencoded_query.c
index b255811..fdcc3e6 100644
--- a/scan_urlencoded_query.c
+++ b/scan_urlencoded_query.c
@@ -21,6 +21,7 @@ size_t scan_urlencoded_query(char **string, char *deststring, int flags) {
21 unsigned char *d = (unsigned char*)deststring; 21 unsigned char *d = (unsigned char*)deststring;
22 register unsigned char b, c; 22 register unsigned char b, c;
23 23
24retry_parsing:
24 while( is_unreserved( c = *s++) ) { 25 while( is_unreserved( c = *s++) ) {
25 if( c=='%') { 26 if( c=='%') {
26 if( ( c = scan_fromhex(*s++) ) == 0xff ) return -1; 27 if( ( c = scan_fromhex(*s++) ) == 0xff ) return -1;
@@ -36,7 +37,9 @@ size_t scan_urlencoded_query(char **string, char *deststring, int flags) {
36 --s; 37 --s;
37 break; 38 break;
38 case '?': 39 case '?':
39 if( flags != SCAN_PATH ) return -1; 40 if( flags == SCAN_PATH ) goto found_terminator;
41 *d++ = c;
42 goto retry_parsing;
40 break; 43 break;
41 case '=': 44 case '=':
42 if( flags != SCAN_SEARCHPATH_PARAM ) return -1; 45 if( flags != SCAN_SEARCHPATH_PARAM ) return -1;
@@ -49,6 +52,7 @@ size_t scan_urlencoded_query(char **string, char *deststring, int flags) {
49 return -1; 52 return -1;
50 } 53 }
51 54
55found_terminator:
52 *string = (char *)s; 56 *string = (char *)s;
53 return d - (unsigned char*)deststring; 57 return d - (unsigned char*)deststring;
54} 58}