summaryrefslogtreecommitdiff
path: root/indra/llcommon/lluriparser.cpp
diff options
context:
space:
mode:
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;