summaryrefslogtreecommitdiff
path: root/indra/llcommon/lluriparser.cpp
diff options
context:
space:
mode:
authorBrad Payne (Vir Linden) <vir@lindenlab.com>2015-04-13 17:19:27 -0400
committerBrad Payne (Vir Linden) <vir@lindenlab.com>2015-04-13 17:19:27 -0400
commit32940ee90b6dae898f83cf99516f18f106246ace (patch)
tree1fca162d8adc5b7aed5a0193627d6caf773f09fd /indra/llcommon/lluriparser.cpp
parentcddfcda1677c4a5d25d2adc54eb4c3aef0953ee1 (diff)
parenta647b8f1cbab13f07ea889c80df28414bc906129 (diff)
merge
Diffstat (limited to 'indra/llcommon/lluriparser.cpp')
-rw-r--r--indra/llcommon/lluriparser.cpp62
1 files changed, 57 insertions, 5 deletions
diff --git a/indra/llcommon/lluriparser.cpp b/indra/llcommon/lluriparser.cpp
index ef4481d32f..8270c630d8 100644
--- a/indra/llcommon/lluriparser.cpp
+++ b/indra/llcommon/lluriparser.cpp
@@ -29,7 +29,7 @@
#include "linden_common.h"
#include "lluriparser.h"
-LLUriParser::LLUriParser(const std::string& u) : mTmpScheme(false), mRes(0)
+LLUriParser::LLUriParser(const std::string& u) : mTmpScheme(false), mNormalizedTmp(false), mRes(0)
{
mState.uri = &mUri;
@@ -118,17 +118,39 @@ void LLUriParser::fragment(const std::string& s)
void LLUriParser::textRangeToString(UriTextRangeA& textRange, std::string& str)
{
+ str = "";
+
+ if(&textRange == NULL)
+ {
+ return;
+ }
+
+ if(textRange.first == NULL)
+ {
+ return;
+ }
+
+ if(textRange.afterLast == NULL)
+ {
+ return;
+ }
+
S32 len = textRange.afterLast - textRange.first;
if (len)
{
- str = textRange.first;
- str = str.substr(0, len);
+ str.assign(textRange.first, len);
}
}
void LLUriParser::extractParts()
{
- if (mTmpScheme)
+ if(&mUri == NULL)
+ {
+ LL_WARNS() << "mUri is NULL for uri: " << mNormalizedUri << LL_ENDL;
+ return;
+ }
+
+ if (mTmpScheme || mNormalizedTmp)
{
mScheme.clear();
}
@@ -157,6 +179,7 @@ void LLUriParser::extractParts()
S32 LLUriParser::normalize()
{
+ mNormalizedTmp = mTmpScheme;
if (!mRes)
{
mRes = uriNormalizeSyntaxExA(&mUri, URI_NORMALIZE_SCHEME | URI_NORMALIZE_HOST);
@@ -175,29 +198,58 @@ S32 LLUriParser::normalize()
if (!mRes)
{
mNormalizedUri = &label_buf[mTmpScheme ? 7 : 0];
+ mTmpScheme = false;
}
}
}
}
+ if(mTmpScheme)
+ {
+ mNormalizedUri = mNormalizedUri.substr(7);
+ mTmpScheme = false;
+ }
+
return mRes;
}
void LLUriParser::glue(std::string& uri) const
{
+ std::string first_part;
+ glueFirst(first_part);
+
+ std::string second_part;
+ glueSecond(second_part);
+
+ uri = first_part + second_part;
+}
+
+void LLUriParser::glueFirst(std::string& uri) const
+{
if (mScheme.size())
{
uri = mScheme;
uri += "://";
}
+ else
+ {
+ uri.clear();
+ }
uri += mHost;
+}
+void LLUriParser::glueSecond(std::string& uri) const
+{
if (mPort.size())
{
- uri += ':';
+ uri = ':';
uri += mPort;
}
+ else
+ {
+ uri.clear();
+ }
uri += mPath;