diff options
author | Tess Chu <tess@lindenlab.com> | 2007-11-15 19:22:19 +0000 |
---|---|---|
committer | Tess Chu <tess@lindenlab.com> | 2007-11-15 19:22:19 +0000 |
commit | 291d99bc66c4c2b8009ba723a43e2e97d24313f9 (patch) | |
tree | 60991ea5744899ac7ac096a4130e43238768db20 /indra/llcommon/lluri.cpp | |
parent | 138bf17c3c51cbf3826a05887d73c49908025f95 (diff) |
svn merge -r73220:73877 svn+ssh://svn/svn/linden/branches/viewer-auth-6
Diffstat (limited to 'indra/llcommon/lluri.cpp')
-rw-r--r-- | indra/llcommon/lluri.cpp | 69 |
1 files changed, 49 insertions, 20 deletions
diff --git a/indra/llcommon/lluri.cpp b/indra/llcommon/lluri.cpp index df790433df..5e4dec7f82 100644 --- a/indra/llcommon/lluri.cpp +++ b/indra/llcommon/lluri.cpp @@ -40,6 +40,8 @@ #include "../llmath/lluuid.h" +// system includes +#include <boost/tokenizer.hpp> // static std::string LLURI::escape(const std::string& str, const std::string & allowed) @@ -130,7 +132,7 @@ LLURI::LLURI() LLURI::LLURI(const std::string& escaped_str) { - std::string::size_type delim_pos, delim_pos2; + std::string::size_type delim_pos; delim_pos = escaped_str.find(':'); std::string temp; if (delim_pos == std::string::npos) @@ -144,13 +146,39 @@ LLURI::LLURI(const std::string& escaped_str) mEscapedOpaque = escaped_str.substr(delim_pos+1); } - if (mScheme == "http" || mScheme == "https" || mScheme == "ftp") + parseAuthorityAndPathUsingOpaque(); + + delim_pos = mEscapedPath.find('?'); + if (delim_pos != std::string::npos) + { + mEscapedQuery = mEscapedPath.substr(delim_pos+1); + mEscapedPath = mEscapedPath.substr(0,delim_pos); + } +} + +static BOOL isDefault(const std::string& scheme, U16 port) +{ + if (scheme == "http") + return port == 80; + if (scheme == "https") + return port == 443; + if (scheme == "ftp") + return port == 21; + + return FALSE; +} + +void LLURI::parseAuthorityAndPathUsingOpaque() +{ + if (mScheme == "http" || mScheme == "https" || + mScheme == "ftp" || mScheme == "secondlife" ) { if (mEscapedOpaque.substr(0,2) != "//") { return; } - + + std::string::size_type delim_pos, delim_pos2; delim_pos = mEscapedOpaque.find('/', 2); delim_pos2 = mEscapedOpaque.find('?', 2); // no path, no query @@ -182,27 +210,12 @@ LLURI::LLURI(const std::string& escaped_str) mEscapedPath = mEscapedOpaque.substr(delim_pos); } } - - delim_pos = mEscapedPath.find('?'); - if (delim_pos != std::string::npos) + else if (mScheme == "about") { - mEscapedQuery = mEscapedPath.substr(delim_pos+1); - mEscapedPath = mEscapedPath.substr(0,delim_pos); + mEscapedPath = mEscapedOpaque; } } -static BOOL isDefault(const std::string& scheme, U16 port) -{ - if (scheme == "http") - return port == 80; - if (scheme == "https") - return port == 443; - if (scheme == "ftp") - return port == 21; - - return FALSE; -} - LLURI::LLURI(const std::string& scheme, const std::string& userName, const std::string& password, @@ -440,6 +453,22 @@ std::string LLURI::path() const return unescape(mEscapedPath); } +LLSD LLURI::pathArray() const +{ + typedef boost::tokenizer<boost::char_separator<char> > tokenizer; + boost::char_separator<char> sep("/", "", boost::drop_empty_tokens); + tokenizer tokens(mEscapedPath, sep); + tokenizer::iterator it = tokens.begin(); + tokenizer::iterator end = tokens.end(); + + LLSD params; + for ( ; it != end; ++it) + { + params.append(*it); + } + return params; +} + std::string LLURI::query() const { return unescape(mEscapedQuery); |