march
2007年12月18日 12:29
void LLPanelDirFindAll::search(const std::string& search_text)
{
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);
}
}
std::string url = gSavedSettings.getString("SearchURLQuery");
std::string substring = "[QUERY]";
url.replace(url.find(substring), substring.length(), query);
(略)