From 0de82a8925e38e39f01a732ee22b27607b820d0b Mon Sep 17 00:00:00 2001 From: erdgeist <> Date: Sat, 9 Dec 2006 12:50:42 +0000 Subject: Fixed parser --- scan_urlencoded_query.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'scan_urlencoded_query.c') 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) { if( ( b = scan_fromhex(*s++) ) == 0xff ) return -1; c=(c<<4)|b; } - *d++ = c; + if(d) *d++ = c; } switch( c ) { case 0: case '\r': case '\n': case ' ': - if ( ( flags & BREAK_AT_WHITESPACE ) == 0 ) return -1; + if( d == (unsigned char*)deststring ) return -2; + --s; break; case '?': - if ( ( flags & BREAK_AT_QUESTIONMARK ) == 0 ) return -1; + if( flags != SCAN_PATH ) return -1; break; case '=': - if ( ( flags & BREAK_AT_EQUALSIGN ) == 0 ) return -1; + if( flags != SCAN_SEARCHPATH_PARAM ) return -1; break; case '&': - if ( ( flags & BREAK_AT_AMPERSAND ) == 0 ) return -1; + if( flags == SCAN_PATH ) return -1; + if( flags == SCAN_SEARCHPATH_PARAM ) --s; break; default: return -1; -- cgit v1.2.3