From e76b5643effc0a38c28a561ce403c97033419398 Mon Sep 17 00:00:00 2001
From: Mnikolenko Productengine <mnikolenko@productengine.com>
Date: Wed, 10 Aug 2016 13:31:25 +0300
Subject: [PATCH] MAINT-6608 FIXED URI parser problem with links with username,
 password

---
 indra/llcommon/lluriparser.cpp |  4 ++--
 indra/llcommon/lluriparser.h   |  2 +-
 indra/llui/llurlentry.cpp      | 12 +++++++++---
 3 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/indra/llcommon/lluriparser.cpp b/indra/llcommon/lluriparser.cpp
index 82d0dc8b4b2..c275b90120d 100644
--- a/indra/llcommon/lluriparser.cpp
+++ b/indra/llcommon/lluriparser.cpp
@@ -205,9 +205,9 @@ void LLUriParser::glue(std::string& uri) const
 	uri = first_part + second_part;
 }
 
-void LLUriParser::glueFirst(std::string& uri) const
+void LLUriParser::glueFirst(std::string& uri, bool use_scheme) const
 {
-	if (mScheme.size())
+	if (use_scheme && mScheme.size())
 	{
 		uri = mScheme;
 		uri += "://";
diff --git a/indra/llcommon/lluriparser.h b/indra/llcommon/lluriparser.h
index 2df8085ae63..cfbf54f3c85 100644
--- a/indra/llcommon/lluriparser.h
+++ b/indra/llcommon/lluriparser.h
@@ -60,7 +60,7 @@ class LL_COMMON_API LLUriParser
 
 	void extractParts();
 	void glue(std::string& uri) const;
-	void glueFirst(std::string& uri) const;
+	void glueFirst(std::string& uri, bool use_scheme = true) const;
 	void glueSecond(std::string& uri) const;
 	bool test() const;
 	S32 normalize();
diff --git a/indra/llui/llurlentry.cpp b/indra/llui/llurlentry.cpp
index e4848362a76..797fae81c47 100644
--- a/indra/llui/llurlentry.cpp
+++ b/indra/llui/llurlentry.cpp
@@ -205,9 +205,15 @@ std::string LLUrlEntryBase::urlToGreyQuery(const std::string &url) const
 
 	std::string label;
 	up.extractParts();
-	up.glueFirst(label);
-	std::string query = url.substr(label.size());
-	return query;
+	up.glueFirst(label, false);
+
+	size_t pos = url.find(label);
+	if (pos == std::string::npos)
+	{
+		return "";
+	}
+	pos += label.size();
+	return url.substr(pos);
 }
 
 
-- 
GitLab