From 9608b6dcac894c5251d9419c66943d6473fa5d41 Mon Sep 17 00:00:00 2001
From: Mnikolenko Productengine <mnikolenko@productengine.com>
Date: Thu, 11 Jun 2020 17:41:59 +0300
Subject: SL-13433 Viewer should recognizes ipv6 links

---
 indra/llui/llurlentry.cpp    | 39 +++++++++++++++++++++++++++++++++++++++
 indra/llui/llurlentry.h      | 13 +++++++++++++
 indra/llui/llurlregistry.cpp |  1 +
 3 files changed, 53 insertions(+)

diff --git a/indra/llui/llurlentry.cpp b/indra/llui/llurlentry.cpp
index 333d03f208..ac86101f69 100644
--- a/indra/llui/llurlentry.cpp
+++ b/indra/llui/llurlentry.cpp
@@ -1475,4 +1475,43 @@ void LLUrlEntryExperienceProfile::onExperienceDetails( const LLSD& experience_de
     callObservers(experience_details[LLExperienceCache::EXPERIENCE_ID].asString(), name, LLStringUtil::null);
 }
 
+//
+// LLUrlEntryEmail Describes an IPv6 address
+//
+LLUrlEntryIPv6::LLUrlEntryIPv6()
+	: LLUrlEntryBase()
+{
+	mHostPath = "https?://\\[([a-f0-9:]+:+)+[a-f0-9]+]";
+	mPattern = boost::regex(mHostPath + "(:\\d{1,5})?(/\\S*)?",
+		boost::regex::perl | boost::regex::icase);
+	mMenuName = "menu_url_http.xml";
+	mTooltip = LLTrans::getString("TooltipHttpUrl");
+}
 
+std::string LLUrlEntryIPv6::getLabel(const std::string &url, const LLUrlLabelCallback &cb)
+{
+	boost::regex regex = boost::regex(mHostPath, boost::regex::perl | boost::regex::icase);
+	boost::match_results<std::string::const_iterator> matches;
+
+	if (boost::regex_search(url, matches, regex))
+	{
+		return  url.substr(0, matches[0].length());
+	}
+	else
+	{
+		return url;
+	}
+}
+
+std::string LLUrlEntryIPv6::getQuery(const std::string &url) const
+{
+	boost::regex regex = boost::regex(mHostPath, boost::regex::perl | boost::regex::icase);
+	boost::match_results<std::string::const_iterator> matches;
+
+	return boost::regex_replace(url, regex, "");
+}
+
+std::string LLUrlEntryIPv6::getUrl(const std::string &string) const
+{
+	return string;
+}
diff --git a/indra/llui/llurlentry.h b/indra/llui/llurlentry.h
index 78c149d9fd..0a0c247a6a 100644
--- a/indra/llui/llurlentry.h
+++ b/indra/llui/llurlentry.h
@@ -513,5 +513,18 @@ public:
 	/*virtual*/ std::string getUrl(const std::string &string) const;
 };
 
+///
+/// LLUrlEntryEmail Describes an IPv6 address
+///
+class LLUrlEntryIPv6 : public LLUrlEntryBase
+{
+public:
+	LLUrlEntryIPv6();
+	/*virtual*/ std::string getLabel(const std::string &url, const LLUrlLabelCallback &cb);
+	/*virtual*/ std::string getUrl(const std::string &string) const;
+	/*virtual*/ std::string getQuery(const std::string &url) const;
+
+	std::string mHostPath;
+};
 
 #endif
diff --git a/indra/llui/llurlregistry.cpp b/indra/llui/llurlregistry.cpp
index ba6fa1e2e9..321a0ec5b9 100644
--- a/indra/llui/llurlregistry.cpp
+++ b/indra/llui/llurlregistry.cpp
@@ -79,6 +79,7 @@ LLUrlRegistry::LLUrlRegistry()
 	mUrlEntrySLLabel = new LLUrlEntrySLLabel();
 	registerUrl(mUrlEntrySLLabel);
 	registerUrl(new LLUrlEntryEmail());
+	registerUrl(new LLUrlEntryIPv6());
 }
 
 LLUrlRegistry::~LLUrlRegistry()
-- 
cgit v1.2.3