CVSROOT: /sources/gnash Module name: gnash Changes by: Sandro Santilli <strk> 08/02/15 21:07:20
Modified files: . : ChangeLog libbase : URL.cpp testsuite/libbase: URLTest.cpp Log message: * libbase/URL.cpp: rewrite parse_querystring using boost::tokenizer, fixing the new test. * testsuite/libbase/URLTest.cpp: new tests fixed. CVSWeb URLs: http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.5665&r2=1.5666 http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/URL.cpp?cvsroot=gnash&r1=1.43&r2=1.44 http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/libbase/URLTest.cpp?cvsroot=gnash&r1=1.19&r2=1.20 Patches: Index: ChangeLog =================================================================== RCS file: /sources/gnash/gnash/ChangeLog,v retrieving revision 1.5665 retrieving revision 1.5666 diff -u -b -r1.5665 -r1.5666 --- ChangeLog 15 Feb 2008 20:50:43 -0000 1.5665 +++ ChangeLog 15 Feb 2008 21:07:19 -0000 1.5666 @@ -1,3 +1,9 @@ +2008-02-15 Sandro Santilli <[EMAIL PROTECTED]> + + * libbase/URL.cpp: rewrite parse_querystring using + boost::tokenizer, fixing the new test. + * testsuite/libbase/URLTest.cpp: new tests fixed. + 2008-02-15 Rob Savoye <[EMAIL PROTECTED]> * macros/glib.m4: Add extra glib for include path, and drop the Index: libbase/URL.cpp =================================================================== RCS file: /sources/gnash/gnash/libbase/URL.cpp,v retrieving revision 1.43 retrieving revision 1.44 diff -u -b -r1.43 -r1.44 --- libbase/URL.cpp 31 Jan 2008 21:38:41 -0000 1.43 +++ libbase/URL.cpp 15 Feb 2008 21:07:20 -0000 1.44 @@ -48,6 +48,7 @@ #endif #include <climits> +#include <boost/tokenizer.hpp> using namespace std; @@ -365,33 +366,43 @@ URL::parse_querystring(const std::string& query_string, std::map<std::string, std::string>& target_map) { - size_t start = 0; - if ( query_string[0] == '?' ) start = 1; - size_t end = query_string.size(); - while ( start < end ) + if ( query_string.empty() ) return; // nothing to do + + std::string qstring=query_string;; + + if ( qstring[0] == '?' ) { - size_t eq = query_string.find("=", start); + qstring=qstring.substr(1); + } + + typedef boost::char_separator<char> Sep; + typedef boost::tokenizer< Sep > Tok; + Tok t1(qstring, Sep("&")); + for(Tok::iterator tit=t1.begin(); tit!=t1.end(); ++tit) + { + const std::string& nameval = *tit; + + string name; + string value; + + size_t eq = nameval.find("="); if ( eq == string::npos ) { - break; // no point of keepign a var + name = nameval; } - - size_t amp=query_string.find("&", start); - if ( amp == string::npos ) { - amp = end; + else + { + name = nameval.substr(0, eq); + value = nameval.substr(eq+1); } - string name = query_string.substr(start, eq-start); - string value = query_string.substr(eq+1, amp-(eq+1)); decode(name); decode(value); target_map[name] = value; - - start = amp+1; - } + } /* public static */ Index: testsuite/libbase/URLTest.cpp =================================================================== RCS file: /sources/gnash/gnash/testsuite/libbase/URLTest.cpp,v retrieving revision 1.19 retrieving revision 1.20 diff -u -b -r1.19 -r1.20 --- testsuite/libbase/URLTest.cpp 15 Feb 2008 10:36:28 -0000 1.19 +++ testsuite/libbase/URLTest.cpp 15 Feb 2008 21:07:20 -0000 1.20 @@ -170,8 +170,8 @@ URL::parse_querystring("\n&inurl_check=3", qs); check_equals(qs.size(), 2); check_equals(qs["inurl_check"], "3"); - xcheck(qs.find("") != qs.end()); - xcheck(qs.find("\n&inurl_check") == qs.end()); + check(qs.find("\n") != qs.end()); + check(qs.find("\n&inurl_check") == qs.end()); // Test query string with embedded path to an .swf // Broken by: _______________________________________________ Gnash-commit mailing list Gnash-commit@gnu.org http://lists.gnu.org/mailman/listinfo/gnash-commit