summaryrefslogtreecommitdiff
path: root/scan_urlencoded_query.c
diff options
context:
space:
mode:
authorerdgeist <>2006-12-09 12:50:42 +0000
committererdgeist <>2006-12-09 12:50:42 +0000
commit0de82a8925e38e39f01a732ee22b27607b820d0b (patch)
tree4c0d6b437f486ab319a2d6aec32e1d3c8aca502b /scan_urlencoded_query.c
parent932242eee7d99559bf8e0b4cec2b140f567a8149 (diff)
Fixed parser
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;