aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llcommon/lluri.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/llcommon/lluri.cpp')
-rw-r--r--linden/indra/llcommon/lluri.cpp69
1 files changed, 49 insertions, 20 deletions
diff --git a/linden/indra/llcommon/lluri.cpp b/linden/indra/llcommon/lluri.cpp
index df79043..5e4dec7 100644
--- a/linden/indra/llcommon/lluri.cpp
+++ b/linden/indra/llcommon/lluri.cpp
@@ -40,6 +40,8 @@
40 40
41#include "../llmath/lluuid.h" 41#include "../llmath/lluuid.h"
42 42
43// system includes
44#include <boost/tokenizer.hpp>
43 45
44// static 46// static
45std::string LLURI::escape(const std::string& str, const std::string & allowed) 47std::string LLURI::escape(const std::string& str, const std::string & allowed)
@@ -130,7 +132,7 @@ LLURI::LLURI()
130 132
131LLURI::LLURI(const std::string& escaped_str) 133LLURI::LLURI(const std::string& escaped_str)
132{ 134{
133 std::string::size_type delim_pos, delim_pos2; 135 std::string::size_type delim_pos;
134 delim_pos = escaped_str.find(':'); 136 delim_pos = escaped_str.find(':');
135 std::string temp; 137 std::string temp;
136 if (delim_pos == std::string::npos) 138 if (delim_pos == std::string::npos)
@@ -144,13 +146,39 @@ LLURI::LLURI(const std::string& escaped_str)
144 mEscapedOpaque = escaped_str.substr(delim_pos+1); 146 mEscapedOpaque = escaped_str.substr(delim_pos+1);
145 } 147 }
146 148
147 if (mScheme == "http" || mScheme == "https" || mScheme == "ftp") 149 parseAuthorityAndPathUsingOpaque();
150
151 delim_pos = mEscapedPath.find('?');
152 if (delim_pos != std::string::npos)
153 {
154 mEscapedQuery = mEscapedPath.substr(delim_pos+1);
155 mEscapedPath = mEscapedPath.substr(0,delim_pos);
156 }
157}
158
159static BOOL isDefault(const std::string& scheme, U16 port)
160{
161 if (scheme == "http")
162 return port == 80;
163 if (scheme == "https")
164 return port == 443;
165 if (scheme == "ftp")
166 return port == 21;
167
168 return FALSE;
169}
170
171void LLURI::parseAuthorityAndPathUsingOpaque()
172{
173 if (mScheme == "http" || mScheme == "https" ||
174 mScheme == "ftp" || mScheme == "secondlife" )
148 { 175 {
149 if (mEscapedOpaque.substr(0,2) != "//") 176 if (mEscapedOpaque.substr(0,2) != "//")
150 { 177 {
151 return; 178 return;
152 } 179 }
153 180
181 std::string::size_type delim_pos, delim_pos2;
154 delim_pos = mEscapedOpaque.find('/', 2); 182 delim_pos = mEscapedOpaque.find('/', 2);
155 delim_pos2 = mEscapedOpaque.find('?', 2); 183 delim_pos2 = mEscapedOpaque.find('?', 2);
156 // no path, no query 184 // no path, no query
@@ -182,27 +210,12 @@ LLURI::LLURI(const std::string& escaped_str)
182 mEscapedPath = mEscapedOpaque.substr(delim_pos); 210 mEscapedPath = mEscapedOpaque.substr(delim_pos);
183 } 211 }
184 } 212 }
185 213 else if (mScheme == "about")
186 delim_pos = mEscapedPath.find('?');
187 if (delim_pos != std::string::npos)
188 { 214 {
189 mEscapedQuery = mEscapedPath.substr(delim_pos+1); 215 mEscapedPath = mEscapedOpaque;
190 mEscapedPath = mEscapedPath.substr(0,delim_pos);
191 } 216 }
192} 217}
193 218
194static BOOL isDefault(const std::string& scheme, U16 port)
195{
196 if (scheme == "http")
197 return port == 80;
198 if (scheme == "https")
199 return port == 443;
200 if (scheme == "ftp")
201 return port == 21;
202
203 return FALSE;
204}
205
206LLURI::LLURI(const std::string& scheme, 219LLURI::LLURI(const std::string& scheme,
207 const std::string& userName, 220 const std::string& userName,
208 const std::string& password, 221 const std::string& password,
@@ -440,6 +453,22 @@ std::string LLURI::path() const
440 return unescape(mEscapedPath); 453 return unescape(mEscapedPath);
441} 454}
442 455
456LLSD LLURI::pathArray() const
457{
458 typedef boost::tokenizer<boost::char_separator<char> > tokenizer;
459 boost::char_separator<char> sep("/", "", boost::drop_empty_tokens);
460 tokenizer tokens(mEscapedPath, sep);
461 tokenizer::iterator it = tokens.begin();
462 tokenizer::iterator end = tokens.end();
463
464 LLSD params;
465 for ( ; it != end; ++it)
466 {
467 params.append(*it);
468 }
469 return params;
470}
471
443std::string LLURI::query() const 472std::string LLURI::query() const
444{ 473{
445 return unescape(mEscapedQuery); 474 return unescape(mEscapedQuery);