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.cpp47
1 files changed, 40 insertions, 7 deletions
diff --git a/indra/llcommon/lluriparser.cpp b/indra/llcommon/lluriparser.cpp
index ef4481d32f..d98bc297e5 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,20 @@ void LLUriParser::fragment(const std::string& s)
void LLUriParser::textRangeToString(UriTextRangeA& textRange, std::string& str)
{
- S32 len = textRange.afterLast - textRange.first;
- if (len)
+ if (textRange.first != NULL && textRange.afterLast != NULL && textRange.first < textRange.afterLast)
{
- str = textRange.first;
- str = str.substr(0, len);
+ const ptrdiff_t len = textRange.afterLast - textRange.first;
+ str.assign(textRange.first, static_cast<std::string::size_type>(len));
+ }
+ else
+ {
+ str = LLStringUtil::null;
}
}
void LLUriParser::extractParts()
{
- if (mTmpScheme)
+ if (mTmpScheme || mNormalizedTmp)
{
mScheme.clear();
}
@@ -157,6 +160,7 @@ void LLUriParser::extractParts()
S32 LLUriParser::normalize()
{
+ mNormalizedTmp = mTmpScheme;
if (!mRes)
{
mRes = uriNormalizeSyntaxExA(&mUri, URI_NORMALIZE_SCHEME | URI_NORMALIZE_HOST);
@@ -175,29 +179,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;