diff options
author | Tess Chu <tess@lindenlab.com> | 2007-11-20 02:53:43 +0000 |
---|---|---|
committer | Tess Chu <tess@lindenlab.com> | 2007-11-20 02:53:43 +0000 |
commit | 2f6c7606241acdf800a2c079b359e7a1db360954 (patch) | |
tree | adb6e6e34f9c3df1e2252b2f763ae20970c0e2d4 /indra/llcommon | |
parent | 813b140d0767146b17acf4ad2fb96fbd5a347c34 (diff) |
svn merge -r 73926:74098 svn+ssh://svn/svn/linden/branches/viewer-auth-7
Diffstat (limited to 'indra/llcommon')
-rw-r--r-- | indra/llcommon/lluri.cpp | 69 | ||||
-rw-r--r-- | indra/llcommon/lluri.h | 7 |
2 files changed, 55 insertions, 21 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); diff --git a/indra/llcommon/lluri.h b/indra/llcommon/lluri.h index 3246dcd81f..bfe673c2f7 100644 --- a/indra/llcommon/lluri.h +++ b/indra/llcommon/lluri.h @@ -107,7 +107,7 @@ public: BOOL defaultPort() const; // true if port is default for scheme const std::string& escapedPath() const { return mEscapedPath; } std::string path() const; // ex.: "/abc/def", includes leading slash - // LLSD pathArray() const; // above decoded into an array of strings + LLSD pathArray() const; // above decoded into an array of strings std::string query() const; // ex.: "x=34", section after "?" const std::string& escapedQuery() const { return mEscapedQuery; } LLSD queryMap() const; // above decoded into a map @@ -135,6 +135,11 @@ public: //@} private: + // only "http", "https", "ftp", and "secondlife" schemes are parsed + // secondlife scheme parses authority as "" and includes it as part of + // the path. See lluri_tut.cpp + // i.e. secondlife://app/login has mAuthority = "" and mPath = "/app/login" + void parseAuthorityAndPathUsingOpaque(); std::string mScheme; std::string mEscapedOpaque; std::string mEscapedAuthority; |