summaryrefslogtreecommitdiff
path: root/scan_urlencoded_query.c
diff options
context:
space:
mode:
Diffstat (limited to 'scan_urlencoded_query.c')
-rw-r--r--scan_urlencoded_query.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/scan_urlencoded_query.c b/scan_urlencoded_query.c
index 6ba7808..3ac01cd 100644
--- a/scan_urlencoded_query.c
+++ b/scan_urlencoded_query.c
@@ -24,21 +24,23 @@ size_t scan_urlencoded_query(char **string, char *deststring, int flags) {
24 if( ( b = scan_fromhex(*s++) ) == 0xff ) return -1; 24 if( ( b = scan_fromhex(*s++) ) == 0xff ) return -1;
25 c=(c<<4)|b; 25 c=(c<<4)|b;
26 } 26 }
27 *d++ = c; 27 if(d) *d++ = c;
28 } 28 }
29 29
30 switch( c ) { 30 switch( c ) {
31 case 0: case '\r': case '\n': case ' ': 31 case 0: case '\r': case '\n': case ' ':
32 if ( ( flags & BREAK_AT_WHITESPACE ) == 0 ) return -1; 32 if( d == (unsigned char*)deststring ) return -2;
33 --s;
33 break; 34 break;
34 case '?': 35 case '?':
35 if ( ( flags & BREAK_AT_QUESTIONMARK ) == 0 ) return -1; 36 if( flags != SCAN_PATH ) return -1;
36 break; 37 break;
37 case '=': 38 case '=':
38 if ( ( flags & BREAK_AT_EQUALSIGN ) == 0 ) return -1; 39 if( flags != SCAN_SEARCHPATH_PARAM ) return -1;
39 break; 40 break;
40 case '&': 41 case '&':
41 if ( ( flags & BREAK_AT_AMPERSAND ) == 0 ) return -1; 42 if( flags == SCAN_PATH ) return -1;
43 if( flags == SCAN_SEARCHPATH_PARAM ) --s;
42 break; 44 break;
43 default: 45 default:
44 return -1; 46 return -1;