diff -r -u linden-orig/indra/llcommon/lluri.cpp linden/indra/llcommon/lluri.cpp --- linden-orig/indra/llcommon/lluri.cpp 2007-12-12 16:14:30.000000000 +0900 +++ linden/indra/llcommon/lluri.cpp 2007-12-21 12:29:15.421875000 +0900 @@ -55,9 +55,11 @@ std::string::value_type c = *it; if(allowed.find(c) == std::string::npos) { + // Do escaping + // A mask is required because of treatment for Sign-extension ostr << "%" << std::uppercase << std::hex << std::setw(2) << std::setfill('0') - << static_cast(c); + << (static_cast(c) & 0xFF); } else { @@ -68,6 +70,50 @@ } // static +std::string LLURI::uriescape(const std::string& str) +{ + if (str.empty()) + { + return str; + } + + // Replace spaces with "+" for use by Google search appliance + // Yes, this actually works for double-spaces + // " foo bar" becomes "+foo++bar" and works fine. JC + + // Since we are already iterating over the query, + // do our own custom escaping here. + + // Our own special set of allowed chars (RFC1738 http://www.ietf.org/rfc/rfc1738.txt) + const char* allowed = + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" + "0123456789" + "-._~$+!*'()"; + + std::string ostr; + std::string::const_iterator it = str.begin(); + for ( ; it != str.end(); ++it ) + { + if ( std::isspace( *it ) ) + { + ostr += '+'; + } + else if(strchr(allowed,*it)) + { + // The character is in the allowed set, just copy it + ostr += *it; + } + else + { + // Do escaping + // A mask is required because of treatment for Sign-extension + ostr += llformat("%%%02X", (*it) & 0xFF); + } + } + return ostr; +} + +// static std::string LLURI::unescape(const std::string& str) { std::ostringstream ostr; diff -r -u linden-orig/indra/llcommon/lluri.h linden/indra/llcommon/lluri.h --- linden-orig/indra/llcommon/lluri.h 2007-12-12 16:14:30.000000000 +0900 +++ linden/indra/llcommon/lluri.h 2007-12-19 10:08:48.031250000 +0900 @@ -131,6 +131,7 @@ static std::string escape( const std::string& str, const std::string & allowed); + static std::string uriescape(const std::string& str); static std::string unescape(const std::string& str); //@} diff -r -u linden-orig/indra/newview/llpaneldirfind.cpp linden/indra/newview/llpaneldirfind.cpp --- linden-orig/indra/newview/llpaneldirfind.cpp 2007-12-12 16:14:34.000000000 +0900 +++ linden/indra/newview/llpaneldirfind.cpp 2007-12-19 12:03:20.046875000 +0900 @@ -179,38 +179,10 @@ { if (!search_text.empty()) { - // Replace spaces with "+" for use by Google search appliance - // Yes, this actually works for double-spaces - // " foo bar" becomes "+foo++bar" and works fine. JC - - // Since we are already iterating over the query, - // do our own custom escaping here. - - // Our own special set of allowed chars (RFC1738 http://www.ietf.org/rfc/rfc1738.txt) - const char* allowed = - "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" - "0123456789" - "-._~$+!*'()"; - std::string query; - std::string::const_iterator it = search_text.begin(); - for ( ; it != search_text.end(); ++it ) - { - if ( std::isspace( *it ) ) - { - query += '+'; - } - else if(strchr(allowed,*it)) - { - // The character is in the allowed set, just copy it - query += *it; - } - else - { - // Do escaping - query += llformat("%%%02X", *it); - } - } + + // Do URI escaping + query = LLURI::uriescape(search_text); std::string url = gSavedSettings.getString("SearchURLQuery"); std::string substring = "[QUERY]";