From 32283a93e08a27e179486a5162367885131dffba Mon Sep 17 00:00:00 2001
From: Eugene Mutavchi <emutavchi@productengine.com>
Date: Fri, 2 Apr 2010 13:36:58 +0300
Subject: [PATCH] Fixed normal bug EXT-6357 (SLapp for object chat does display
 an inspector) - added new LLUrlEntry to support
 'secondlife:///app/objectim/{UUID}/' SLapps. Fixed passing the SLURL to
 inspect_remote_object floater. Reviewed by Vadim Savchuk,
 https://codereview.productengine.com/secondlife/r/158/

--HG--
branch : product-engine
---
 indra/llui/llurlentry.cpp       | 31 ++++++++++++++++++++++++++++++-
 indra/llui/llurlentry.h         | 12 ++++++++++++
 indra/llui/llurlregistry.cpp    |  1 +
 indra/newview/llchathistory.cpp |  2 +-
 4 files changed, 44 insertions(+), 2 deletions(-)

diff --git a/indra/llui/llurlentry.cpp b/indra/llui/llurlentry.cpp
index e8e34596730..2f93ab0f042 100644
--- a/indra/llui/llurlentry.cpp
+++ b/indra/llui/llurlentry.cpp
@@ -493,6 +493,35 @@ std::string LLUrlEntryInventory::getLabel(const std::string &url, const LLUrlLab
 	return LLURI::unescape(label.empty() ? url : label);
 }
 
+//
+// LLUrlEntryObjectIM Describes a Second Life inspector for the object Url, e.g.,
+// secondlife:///app/objectim/7bcd7864-da6b-e43f-4486-91d28a28d95b?name=Object&owner=3de548e1-57be-cfea-2b78-83ae3ad95998&slurl=Danger!%20Danger!/200/200/30/&groupowned=1
+//
+LLUrlEntryObjectIM::LLUrlEntryObjectIM()
+{
+	mPattern = boost::regex("secondlife:///app/objectim/[\\da-f-]+\?.*",
+							boost::regex::perl|boost::regex::icase);
+	mMenuName = "menu_url_objectim.xml";
+}
+
+std::string LLUrlEntryObjectIM::getLabel(const std::string &url, const LLUrlLabelCallback &cb)
+{
+	LLURI uri(url);
+	LLSD query_map = uri.queryMap();
+	if (query_map.has("name"))
+		return query_map["name"];
+	return unescapeUrl(url);
+}
+
+std::string LLUrlEntryObjectIM::getLocation(const std::string &url) const
+{
+	LLURI uri(url);
+	LLSD query_map = uri.queryMap();
+	if (query_map.has("slurl"))
+		return query_map["slurl"];
+	return LLUrlEntryBase::getLocation(url);
+}
+
 ///
 /// LLUrlEntryParcel Describes a Second Life parcel Url, e.g.,
 /// secondlife:///app/parcel/0000060e-4b39-e00b-d0c3-d98b1934e3a8/about
@@ -515,7 +544,7 @@ std::string LLUrlEntryParcel::getLabel(const std::string &url, const LLUrlLabelC
 //
 LLUrlEntryPlace::LLUrlEntryPlace()
 {
-	mPattern = boost::regex("secondlife://\\S+/?(\\d+/\\d+/\\d+|\\d+/\\d+)/?",
+	mPattern = boost::regex("secondlife://(?!/)\\S+/?(\\d+/\\d+/\\d+|\\d+/\\d+)/?",
 							boost::regex::perl|boost::regex::icase);
 	mMenuName = "menu_url_slurl.xml";
 	mTooltip = LLTrans::getString("TooltipSLURL");
diff --git a/indra/llui/llurlentry.h b/indra/llui/llurlentry.h
index 84d09687798..29575d752ce 100644
--- a/indra/llui/llurlentry.h
+++ b/indra/llui/llurlentry.h
@@ -201,6 +201,18 @@ class LLUrlEntryInventory : public LLUrlEntryBase
 private:
 };
 
+///
+/// LLUrlEntryObjectIM Describes a Second Life inspector for the object Url, e.g.,
+/// secondlife:///app/objectim/7bcd7864-da6b-e43f-4486-91d28a28d95b?name=Object&owner=3de548e1-57be-cfea-2b78-83ae3ad95998&slurl=Danger!%20Danger!/200/200/30/&groupowned=1
+///
+class LLUrlEntryObjectIM : public LLUrlEntryBase
+{
+public:
+	LLUrlEntryObjectIM();
+	/*virtual*/ std::string getLabel(const std::string &url, const LLUrlLabelCallback &cb);
+	/*virtual*/ std::string getLocation(const std::string &url) const;
+private:
+};
 
 ///
 /// LLUrlEntryParcel Describes a Second Life parcel Url, e.g.,
diff --git a/indra/llui/llurlregistry.cpp b/indra/llui/llurlregistry.cpp
index faa02e19040..7e09a5a919b 100644
--- a/indra/llui/llurlregistry.cpp
+++ b/indra/llui/llurlregistry.cpp
@@ -55,6 +55,7 @@ LLUrlRegistry::LLUrlRegistry()
 	registerUrl(new LLUrlEntryWorldMap());
 	registerUrl(new LLUrlEntryPlace());
 	registerUrl(new LLUrlEntryInventory());
+	registerUrl(new LLUrlEntryObjectIM());
 	//LLUrlEntrySL and LLUrlEntrySLLabel have more common pattern, 
 	//so it should be registered in the end of list
 	registerUrl(new LLUrlEntrySL());
diff --git a/indra/newview/llchathistory.cpp b/indra/newview/llchathistory.cpp
index ec5e61f3841..68c31d87fac 100644
--- a/indra/newview/llchathistory.cpp
+++ b/indra/newview/llchathistory.cpp
@@ -93,7 +93,7 @@ class LLObjectIMHandler : public LLCommandHandler
 		payload["object_id"] = object_id;
 		payload["owner_id"] = query_map["owner"];
 		payload["name"] = query_map["name"];
-		payload["slurl"] = query_map["slurl"];
+		payload["slurl"] = LLWeb::escapeURL(query_map["slurl"]);
 		payload["group_owned"] = query_map["groupowned"];
 		LLFloaterReg::showInstance("inspect_remote_object", payload);
 		return true;
-- 
GitLab