summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
authorLynx Linden <lynx@lindenlab.com>2010-02-02 17:19:14 +0000
committerLynx Linden <lynx@lindenlab.com>2010-02-02 17:19:14 +0000
commite563a07659b74b2dca850834a44c3b92ff993b44 (patch)
tree00d888fdd800be481ab6662a601ce6642f8e715e /indra
parent4ad357ec70e15afdfe78816990cb23c7ba17619c (diff)
DEV-32540: Lots of object IM and SLurl improvements
- Don't let object names that are URLs override links to display the remote object inspector - Don't hyperlink the object name in the remote object inspector - Made the <nolink>...</nolink> regex more robust and made it support non-URLs between the tags, so that we don't get random <nolink> tags when trying to disable URLs in user-typed text. - Improved the llurlentry unit test and added some more test cases. - Hooked up another LLViewerMessage code path to objectim SLapps to pass down the owner and slurl information. - Made a few LLUrlEntryBase methods be const methods, because they are - Fixed a bug in the remote object inspector where it would never show the teleport URL.
Diffstat (limited to 'indra')
-rw-r--r--indra/llui/llurlentry.cpp20
-rw-r--r--indra/llui/llurlentry.h13
-rw-r--r--indra/llui/llurlregistry.cpp3
-rw-r--r--indra/llui/tests/llurlentry_test.cpp305
-rw-r--r--indra/newview/llchathistory.cpp19
-rw-r--r--indra/newview/llinspectremoteobject.cpp5
-rw-r--r--indra/newview/llviewermessage.cpp5
7 files changed, 203 insertions, 167 deletions
diff --git a/indra/llui/llurlentry.cpp b/indra/llui/llurlentry.cpp
index 58148ad2aa..b20de914a0 100644
--- a/indra/llui/llurlentry.cpp
+++ b/indra/llui/llurlentry.cpp
@@ -49,7 +49,7 @@ LLUrlEntryBase::~LLUrlEntryBase()
{
}
-std::string LLUrlEntryBase::getUrl(const std::string &string)
+std::string LLUrlEntryBase::getUrl(const std::string &string) const
{
return escapeUrl(string);
}
@@ -89,7 +89,7 @@ std::string LLUrlEntryBase::escapeUrl(const std::string &url) const
return LLURI::escape(url, no_escape_chars, true);
}
-std::string LLUrlEntryBase::getLabelFromWikiLink(const std::string &url)
+std::string LLUrlEntryBase::getLabelFromWikiLink(const std::string &url) const
{
// return the label part from [http://www.example.org Label]
const char *text = url.c_str();
@@ -105,7 +105,7 @@ std::string LLUrlEntryBase::getLabelFromWikiLink(const std::string &url)
return unescapeUrl(url.substr(start, url.size()-start-1));
}
-std::string LLUrlEntryBase::getUrlFromWikiLink(const std::string &string)
+std::string LLUrlEntryBase::getUrlFromWikiLink(const std::string &string) const
{
// return the url part from [http://www.example.org Label]
const char *text = string.c_str();
@@ -192,7 +192,7 @@ std::string LLUrlEntryHTTPLabel::getLabel(const std::string &url, const LLUrlLab
return getLabelFromWikiLink(url);
}
-std::string LLUrlEntryHTTPLabel::getUrl(const std::string &string)
+std::string LLUrlEntryHTTPLabel::getUrl(const std::string &string) const
{
return getUrlFromWikiLink(string);
}
@@ -217,7 +217,7 @@ std::string LLUrlEntryHTTPNoProtocol::getLabel(const std::string &url, const LLU
return unescapeUrl(url);
}
-std::string LLUrlEntryHTTPNoProtocol::getUrl(const std::string &string)
+std::string LLUrlEntryHTTPNoProtocol::getUrl(const std::string &string) const
{
if (string.find("://") == std::string::npos)
{
@@ -597,7 +597,7 @@ std::string LLUrlEntrySLLabel::getLabel(const std::string &url, const LLUrlLabel
return getLabelFromWikiLink(url);
}
-std::string LLUrlEntrySLLabel::getUrl(const std::string &string)
+std::string LLUrlEntrySLLabel::getUrl(const std::string &string) const
{
return getUrlFromWikiLink(string);
}
@@ -648,14 +648,18 @@ std::string LLUrlEntryWorldMap::getLocation(const std::string &url) const
//
LLUrlEntryNoLink::LLUrlEntryNoLink()
{
- mPattern = boost::regex("<nolink>[^[:space:]<]+</nolink>",
+ mPattern = boost::regex("<nolink>[^<]*</nolink>",
boost::regex::perl|boost::regex::icase);
mDisabledLink = true;
}
-std::string LLUrlEntryNoLink::getLabel(const std::string &url, const LLUrlLabelCallback &cb)
+std::string LLUrlEntryNoLink::getUrl(const std::string &url) const
{
// return the text between the <nolink> and </nolink> tags
return url.substr(8, url.size()-8-9);
}
+std::string LLUrlEntryNoLink::getLabel(const std::string &url, const LLUrlLabelCallback &cb)
+{
+ return getUrl(url);
+}
diff --git a/indra/llui/llurlentry.h b/indra/llui/llurlentry.h
index 94455ac247..3abada0f24 100644
--- a/indra/llui/llurlentry.h
+++ b/indra/llui/llurlentry.h
@@ -71,7 +71,7 @@ public:
boost::regex getPattern() const { return mPattern; }
/// Return the url from a string that matched the regex
- virtual std::string getUrl(const std::string &string);
+ virtual std::string getUrl(const std::string &string) const;
/// Given a matched Url, return a label for the Url
virtual std::string getLabel(const std::string &url, const LLUrlLabelCallback &cb) { return url; }
@@ -98,8 +98,8 @@ protected:
std::string getIDStringFromUrl(const std::string &url) const;
std::string escapeUrl(const std::string &url) const;
std::string unescapeUrl(const std::string &url) const;
- std::string getLabelFromWikiLink(const std::string &url);
- std::string getUrlFromWikiLink(const std::string &string);
+ std::string getLabelFromWikiLink(const std::string &url) const;
+ std::string getUrlFromWikiLink(const std::string &string) const;
void addObserver(const std::string &id, const std::string &url, const LLUrlLabelCallback &cb);
void callObservers(const std::string &id, const std::string &label);
@@ -135,7 +135,7 @@ class LLUrlEntryHTTPLabel : public LLUrlEntryBase
public:
LLUrlEntryHTTPLabel();
/*virtual*/ std::string getLabel(const std::string &url, const LLUrlLabelCallback &cb);
- /*virtual*/ std::string getUrl(const std::string &string);
+ /*virtual*/ std::string getUrl(const std::string &string) const;
};
///
@@ -146,7 +146,7 @@ class LLUrlEntryHTTPNoProtocol : public LLUrlEntryBase
public:
LLUrlEntryHTTPNoProtocol();
/*virtual*/ std::string getLabel(const std::string &url, const LLUrlLabelCallback &cb);
- /*virtual*/ std::string getUrl(const std::string &string);
+ /*virtual*/ std::string getUrl(const std::string &string) const;
};
///
@@ -256,7 +256,7 @@ class LLUrlEntrySLLabel : public LLUrlEntryBase
public:
LLUrlEntrySLLabel();
/*virtual*/ std::string getLabel(const std::string &url, const LLUrlLabelCallback &cb);
- /*virtual*/ std::string getUrl(const std::string &string);
+ /*virtual*/ std::string getUrl(const std::string &string) const;
};
///
@@ -279,6 +279,7 @@ class LLUrlEntryNoLink : public LLUrlEntryBase
public:
LLUrlEntryNoLink();
/*virtual*/ std::string getLabel(const std::string &url, const LLUrlLabelCallback &cb);
+ /*virtual*/ std::string getUrl(const std::string &string) const;
};
#endif
diff --git a/indra/llui/llurlregistry.cpp b/indra/llui/llurlregistry.cpp
index 55eb8950e9..722dbe41b3 100644
--- a/indra/llui/llurlregistry.cpp
+++ b/indra/llui/llurlregistry.cpp
@@ -132,7 +132,8 @@ static bool stringHasUrl(const std::string &text)
text.find(".com") != std::string::npos ||
text.find(".net") != std::string::npos ||
text.find(".edu") != std::string::npos ||
- text.find(".org") != std::string::npos);
+ text.find(".org") != std::string::npos ||
+ text.find("<nolink>") != std::string::npos);
}
bool LLUrlRegistry::findUrl(const std::string &text, LLUrlMatch &match, const LLUrlLabelCallback &cb)
diff --git a/indra/llui/tests/llurlentry_test.cpp b/indra/llui/tests/llurlentry_test.cpp
index bc97cf3df2..cbb303a059 100644
--- a/indra/llui/tests/llurlentry_test.cpp
+++ b/indra/llui/tests/llurlentry_test.cpp
@@ -52,9 +52,10 @@ namespace
namespace tut
{
- void testRegex(const std::string &testname, boost::regex regex,
+ void testRegex(const std::string &testname, LLUrlEntryBase &entry,
const char *text, const std::string &expected)
{
+ boost::regex regex = entry.getPattern();
std::string url = "";
boost::cmatch result;
bool found = boost::regex_search(text, result, regex);
@@ -62,7 +63,7 @@ namespace tut
{
S32 start = static_cast<U32>(result[0].first - text);
S32 end = static_cast<U32>(result[0].second - text);
- url = std::string(text+start, end-start);
+ url = entry.getUrl(std::string(text+start, end-start));
}
ensure_equals(testname, url, expected);
}
@@ -74,74 +75,73 @@ namespace tut
// test LLUrlEntryHTTP - standard http Urls
//
LLUrlEntryHTTP url;
- boost::regex r = url.getPattern();
- testRegex("no valid url", r,
+ testRegex("no valid url", url,
"htp://slurl.com/",
"");
- testRegex("simple http (1)", r,
+ testRegex("simple http (1)", url,
"http://slurl.com/",
"http://slurl.com/");
- testRegex("simple http (2)", r,
+ testRegex("simple http (2)", url,
"http://slurl.com",
"http://slurl.com");
- testRegex("simple http (3)", r,
+ testRegex("simple http (3)", url,
"http://slurl.com/about.php",
"http://slurl.com/about.php");
- testRegex("simple https", r,
+ testRegex("simple https", url,
"https://slurl.com/about.php",
"https://slurl.com/about.php");
- testRegex("http in text (1)", r,
+ testRegex("http in text (1)", url,
"XX http://slurl.com/ XX",
"http://slurl.com/");
- testRegex("http in text (2)", r,
+ testRegex("http in text (2)", url,
"XX http://slurl.com/about.php XX",
"http://slurl.com/about.php");
- testRegex("https in text", r,
+ testRegex("https in text", url,
"XX https://slurl.com/about.php XX",
"https://slurl.com/about.php");
- testRegex("two http urls", r,
+ testRegex("two http urls", url,
"XX http://slurl.com/about.php http://secondlife.com/ XX",
"http://slurl.com/about.php");
- testRegex("http url with port and username", r,
+ testRegex("http url with port and username", url,
"XX http://nobody@slurl.com:80/about.php http://secondlife.com/ XX",
"http://nobody@slurl.com:80/about.php");
- testRegex("http url with port, username, and query string", r,
+ testRegex("http url with port, username, and query string", url,
"XX http://nobody@slurl.com:80/about.php?title=hi%20there http://secondlife.com/ XX",
"http://nobody@slurl.com:80/about.php?title=hi%20there");
// note: terminating commas will be removed by LLUrlRegistry:findUrl()
- testRegex("http url with commas in middle and terminating", r,
+ testRegex("http url with commas in middle and terminating", url,
"XX http://slurl.com/?title=Hi,There, XX",
"http://slurl.com/?title=Hi,There,");
// note: terminating periods will be removed by LLUrlRegistry:findUrl()
- testRegex("http url with periods in middle and terminating", r,
+ testRegex("http url with periods in middle and terminating", url,
"XX http://slurl.com/index.php. XX",
"http://slurl.com/index.php.");
// DEV-19842: Closing parenthesis ")" breaks urls
- testRegex("http url with brackets (1)", r,
+ testRegex("http url with brackets (1)", url,
"XX http://en.wikipedia.org/wiki/JIRA_(software) XX",
"http://en.wikipedia.org/wiki/JIRA_(software)");
// DEV-19842: Closing parenthesis ")" breaks urls
- testRegex("http url with brackets (2)", r,
+ testRegex("http url with brackets (2)", url,
"XX http://jira.secondlife.com/secure/attachment/17990/eggy+avs+in+1.21.0+(93713)+public+nightly.jpg XX",
"http://jira.secondlife.com/secure/attachment/17990/eggy+avs+in+1.21.0+(93713)+public+nightly.jpg");
// DEV-10353: URLs in chat log terminated incorrectly when newline in chat
- testRegex("http url with newlines", r,
+ testRegex("http url with newlines", url,
"XX\nhttp://www.secondlife.com/\nXX",
"http://www.secondlife.com/");
}
@@ -153,39 +153,38 @@ namespace tut
// test LLUrlEntryHTTPLabel - wiki-style http Urls with labels
//
LLUrlEntryHTTPLabel url;
- boost::regex r = url.getPattern();
- testRegex("invalid wiki url [1]", r,
+ testRegex("invalid wiki url [1]", url,
"[http://www.example.org]",
"");
- testRegex("invalid wiki url [2]", r,
+ testRegex("invalid wiki url [2]", url,
"[http://www.example.org",
"");
- testRegex("invalid wiki url [3]", r,
+ testRegex("invalid wiki url [3]", url,
"[http://www.example.org Label",
"");
- testRegex("example.org with label (spaces)", r,
+ testRegex("example.org with label (spaces)", url,
"[http://www.example.org Text]",
- "[http://www.example.org Text]");
+ "http://www.example.org");
- testRegex("example.org with label (tabs)", r,
+ testRegex("example.org with label (tabs)", url,
"[http://www.example.org\t Text]",
- "[http://www.example.org\t Text]");
+ "http://www.example.org");
- testRegex("SL http URL with label", r,
+ testRegex("SL http URL with label", url,
"[http://www.secondlife.com/ Second Life]",
- "[http://www.secondlife.com/ Second Life]");
+ "http://www.secondlife.com/");
- testRegex("SL https URL with label", r,
+ testRegex("SL https URL with label", url,
"XXX [https://www.secondlife.com/ Second Life] YYY",
- "[https://www.secondlife.com/ Second Life]");
+ "https://www.secondlife.com/");
- testRegex("SL http URL with label", r,
+ testRegex("SL http URL with label", url,
"[http://www.secondlife.com/?test=Hi%20There Second Life]",
- "[http://www.secondlife.com/?test=Hi%20There Second Life]");
+ "http://www.secondlife.com/?test=Hi%20There");
}
template<> template<>
@@ -195,69 +194,68 @@ namespace tut
// test LLUrlEntrySLURL - second life URLs
//
LLUrlEntrySLURL url;
- boost::regex r = url.getPattern();
- testRegex("no valid slurl [1]", r,
+ testRegex("no valid slurl [1]", url,
"htp://slurl.com/secondlife/Ahern/50/50/50/",
"");
- testRegex("no valid slurl [2]", r,
+ testRegex("no valid slurl [2]", url,
"http://slurl.com/secondlife/",
"");
- testRegex("no valid slurl [3]", r,
+ testRegex("no valid slurl [3]", url,
"hhtp://slurl.com/secondlife/Ahern/50/FOO/50/",
"");
- testRegex("Ahern (50,50,50) [1]", r,
+ testRegex("Ahern (50,50,50) [1]", url,
"http://slurl.com/secondlife/Ahern/50/50/50/",
"http://slurl.com/secondlife/Ahern/50/50/50/");
- testRegex("Ahern (50,50,50) [2]", r,
+ testRegex("Ahern (50,50,50) [2]", url,
"XXX http://slurl.com/secondlife/Ahern/50/50/50/ XXX",
"http://slurl.com/secondlife/Ahern/50/50/50/");
- testRegex("Ahern (50,50,50) [3]", r,
+ testRegex("Ahern (50,50,50) [3]", url,
"XXX http://slurl.com/secondlife/Ahern/50/50/50 XXX",
"http://slurl.com/secondlife/Ahern/50/50/50");
- testRegex("Ahern (50,50,50) multicase", r,
+ testRegex("Ahern (50,50,50) multicase", url,
"XXX http://SLUrl.com/SecondLife/Ahern/50/50/50/ XXX",
"http://SLUrl.com/SecondLife/Ahern/50/50/50/");
- testRegex("Ahern (50,50) [1]", r,
+ testRegex("Ahern (50,50) [1]", url,
"XXX http://slurl.com/secondlife/Ahern/50/50/ XXX",
"http://slurl.com/secondlife/Ahern/50/50/");
- testRegex("Ahern (50,50) [2]", r,
+ testRegex("Ahern (50,50) [2]", url,
"XXX http://slurl.com/secondlife/Ahern/50/50 XXX",
"http://slurl.com/secondlife/Ahern/50/50");
- testRegex("Ahern (50)", r,
+ testRegex("Ahern (50)", url,
"XXX http://slurl.com/secondlife/Ahern/50 XXX",
"http://slurl.com/secondlife/Ahern/50");
- testRegex("Ahern", r,
+ testRegex("Ahern", url,
"XXX http://slurl.com/secondlife/Ahern/ XXX",
"http://slurl.com/secondlife/Ahern/");
- testRegex("Ahern SLURL with title", r,
+ testRegex("Ahern SLURL with title", url,
"XXX http://slurl.com/secondlife/Ahern/50/50/50/?title=YOUR%20TITLE%20HERE! XXX",
"http://slurl.com/secondlife/Ahern/50/50/50/?title=YOUR%20TITLE%20HERE!");
- testRegex("Ahern SLURL with msg", r,
+ testRegex("Ahern SLURL with msg", url,
"XXX http://slurl.com/secondlife/Ahern/50/50/50/?msg=Your%20text%20here. XXX",
"http://slurl.com/secondlife/Ahern/50/50/50/?msg=Your%20text%20here.");
// DEV-21577: In-world SLURLs containing "(" or ")" are not treated as a hyperlink in chat
- testRegex("SLURL with brackets", r,
+ testRegex("SLURL with brackets", url,
"XXX http://slurl.com/secondlife/Burning%20Life%20(Hyper)/27/210/30 XXX",
"http://slurl.com/secondlife/Burning%20Life%20(Hyper)/27/210/30");
// DEV-35459: SLURLs and teleport Links not parsed properly
- testRegex("SLURL with quote", r,
+ testRegex("SLURL with quote", url,
"XXX http://slurl.com/secondlife/A'ksha%20Oasis/41/166/701 XXX",
- "http://slurl.com/secondlife/A'ksha%20Oasis/41/166/701");
+ "http://slurl.com/secondlife/A%27ksha%20Oasis/41/166/701");
}
template<> template<>
@@ -267,25 +265,24 @@ namespace tut
// test LLUrlEntryAgent - secondlife://app/agent Urls
//
LLUrlEntryAgent url;
- boost::regex r = url.getPattern();
- testRegex("Invalid Agent Url", r,
+ testRegex("Invalid Agent Url", url,
"secondlife:///app/agent/0e346d8b-4433-4d66-XXXX-fd37083abc4c/about",
"");
- testRegex("Agent Url ", r,
+ testRegex("Agent Url ", url,
"secondlife:///app/agent/0e346d8b-4433-4d66-a6b0-fd37083abc4c/about",
"secondlife:///app/agent/0e346d8b-4433-4d66-a6b0-fd37083abc4c/about");
- testRegex("Agent Url in text", r,
+ testRegex("Agent Url in text", url,
"XXX secondlife:///app/agent/0e346d8b-4433-4d66-a6b0-fd37083abc4c/about XXX",
"secondlife:///app/agent/0e346d8b-4433-4d66-a6b0-fd37083abc4c/about");
- testRegex("Agent Url multicase", r,
+ testRegex("Agent Url multicase", url,
"XXX secondlife:///App/AGENT/0E346D8B-4433-4d66-a6b0-fd37083abc4c/About XXX",
"secondlife:///App/AGENT/0E346D8B-4433-4d66-a6b0-fd37083abc4c/About");
- testRegex("Agent Url alternate command", r,
+ testRegex("Agent Url alternate command", url,
"XXX secondlife:///App/AGENT/0E346D8B-4433-4d66-a6b0-fd37083abc4c/foobar",
"secondlife:///App/AGENT/0E346D8B-4433-4d66-a6b0-fd37083abc4c/foobar");
@@ -298,25 +295,24 @@ namespace tut
// test LLUrlEntryGroup - secondlife://app/group Urls
//
LLUrlEntryGroup url;
- boost::regex r = url.getPattern();
- testRegex("Invalid Group Url", r,
+ testRegex("Invalid Group Url", url,
"secondlife:///app/group/00005ff3-4044-c79f-XXXX-fb28ae0df991/about",
"");
- testRegex("Group Url ", r,
+ testRegex("Group Url ", url,
"secondlife:///app/group/00005ff3-4044-c79f-9de8-fb28ae0df991/about",
"secondlife:///app/group/00005ff3-4044-c79f-9de8-fb28ae0df991/about");
- testRegex("Group Url ", r,
+ testRegex("Group Url ", url,
"secondlife:///app/group/00005ff3-4044-c79f-9de8-fb28ae0df991/inspect",
"secondlife:///app/group/00005ff3-4044-c79f-9de8-fb28ae0df991/inspect");
- testRegex("Group Url in text", r,
+ testRegex("Group Url in text", url,
"XXX secondlife:///app/group/00005ff3-4044-c79f-9de8-fb28ae0df991/about XXX",
"secondlife:///app/group/00005ff3-4044-c79f-9de8-fb28ae0df991/about");
- testRegex("Group Url multicase", r,
+ testRegex("Group Url multicase", url,
"XXX secondlife:///APP/Group/00005FF3-4044-c79f-9de8-fb28ae0df991/About XXX",
"secondlife:///APP/Group/00005FF3-4044-c79f-9de8-fb28ae0df991/About");
}
@@ -328,45 +324,44 @@ namespace tut
// test LLUrlEntryPlace - secondlife://<location> URLs
//
LLUrlEntryPlace url;
- boost::regex r = url.getPattern();
- testRegex("no valid slurl [1]", r,
+ testRegex("no valid slurl [1]", url,
"secondlife://Ahern/FOO/50/",
"");
- testRegex("Ahern (50,50,50) [1]", r,
+ testRegex("Ahern (50,50,50) [1]", url,
"secondlife://Ahern/50/50/50/",
"secondlife://Ahern/50/50/50/");
- testRegex("Ahern (50,50,50) [2]", r,
+ testRegex("Ahern (50,50,50) [2]", url,
"XXX secondlife://Ahern/50/50/50/ XXX",
"secondlife://Ahern/50/50/50/");
- testRegex("Ahern (50,50,50) [3]", r,
+ testRegex("Ahern (50,50,50) [3]", url,
"XXX secondlife://Ahern/50/50/50 XXX",
"secondlife://Ahern/50/50/50");
- testRegex("Ahern (50,50,50) multicase", r,
+ testRegex("Ahern (50,50,50) multicase", url,
"XXX SecondLife://Ahern/50/50/50/ XXX",
"SecondLife://Ahern/50/50/50/");
- testRegex("Ahern (50,50) [1]", r,
+ testRegex("Ahern (50,50) [1]", url,
"XXX secondlife://Ahern/50/50/ XXX",
"secondlife://Ahern/50/50/");
- testRegex("Ahern (50,50) [2]", r,
+ testRegex("Ahern (50,50) [2]", url,
"XXX secondlife://Ahern/50/50 XXX",
"secondlife://Ahern/50/50");
// DEV-21577: In-world SLURLs containing "(" or ")" are not treated as a hyperlink in chat
- testRegex("SLURL with brackets", r,
+ testRegex("SLURL with brackets", url,
"XXX secondlife://Burning%20Life%20(Hyper)/27/210/30 XXX",
"secondlife://Burning%20Life%20(Hyper)/27/210/30");
// DEV-35459: SLURLs and teleport Links not parsed properly
- testRegex("SLURL with quote", r,
+ testRegex("SLURL with quote", url,
"XXX secondlife://A'ksha%20Oasis/41/166/701 XXX",
- "secondlife://A'ksha%20Oasis/41/166/701");
+ "secondlife://A%27ksha%20Oasis/41/166/701");
}
template<> template<>
@@ -376,21 +371,20 @@ namespace tut
// test LLUrlEntryParcel - secondlife://app/parcel Urls
//
LLUrlEntryParcel url;
- boost::regex r = url.getPattern();
- testRegex("Invalid Classified Url", r,
+ testRegex("Invalid Classified Url", url,
"secondlife:///app/parcel/0000060e-4b39-e00b-XXXX-d98b1934e3a8/about",
"");
- testRegex("Classified Url ", r,
+ testRegex("Classified Url ", url,
"secondlife:///app/parcel/0000060e-4b39-e00b-d0c3-d98b1934e3a8/about",
"secondlife:///app/parcel/0000060e-4b39-e00b-d0c3-d98b1934e3a8/about");
- testRegex("Classified Url in text", r,
+ testRegex("Classified Url in text", url,
"XXX secondlife:///app/parcel/0000060e-4b39-e00b-d0c3-d98b1934e3a8/about XXX",
"secondlife:///app/parcel/0000060e-4b39-e00b-d0c3-d98b1934e3a8/about");
- testRegex("Classified Url multicase", r,
+ testRegex("Classified Url multicase", url,
"XXX secondlife:///APP/Parcel/0000060e-4b39-e00b-d0c3-d98b1934e3a8/About XXX",
"secondlife:///APP/Parcel/0000060e-4b39-e00b-d0c3-d98b1934e3a8/About");
}
@@ -401,73 +395,72 @@ namespace tut
// test LLUrlEntryTeleport - secondlife://app/teleport URLs
//
LLUrlEntryTeleport url;
- boost::regex r = url.getPattern();
- testRegex("no valid teleport [1]", r,
+ testRegex("no valid teleport [1]", url,
"http://slurl.com/secondlife/Ahern/50/50/50/",
"");
- testRegex("no valid teleport [2]", r,
+ testRegex("no valid teleport [2]", url,
"secondlife:///app/teleport/",
"");
- testRegex("no valid teleport [3]", r,
+ testRegex("no valid teleport [3]", url,
"second-life:///app/teleport/Ahern/50/50/50/",
"");
- testRegex("no valid teleport [3]", r,
+ testRegex("no valid teleport [3]", url,
"hhtp://slurl.com/secondlife/Ahern/50/FOO/50/",
"");
- testRegex("Ahern (50,50,50) [1]", r,
+ testRegex("Ahern (50,50,50) [1]", url,
"secondlife:///app/teleport/Ahern/50/50/50/",
"secondlife:///app/teleport/Ahern/50/50/50/");
- testRegex("Ahern (50,50,50) [2]", r,
+ testRegex("Ahern (50,50,50) [2]", url,
"XXX secondlife:///app/teleport/Ahern/50/50/50/ XXX",
"secondlife:///app/teleport/Ahern/50/50/50/");
- testRegex("Ahern (50,50,50) [3]", r,
+ testRegex("Ahern (50,50,50) [3]", url,
"XXX secondlife:///app/teleport/Ahern/50/50/50 XXX",
"secondlife:///app/teleport/Ahern/50/50/50");
- testRegex("Ahern (50,50,50) multicase", r,
+ testRegex("Ahern (50,50,50) multicase", url,
"XXX secondlife:///app/teleport/Ahern/50/50/50/ XXX",
"secondlife:///app/teleport/Ahern/50/50/50/");
- testRegex("Ahern (50,50) [1]", r,
+ testRegex("Ahern (50,50) [1]", url,
"XXX secondlife:///app/teleport/Ahern/50/50/ XXX",
"secondlife:///app/teleport/Ahern/50/50/");
- testRegex("Ahern (50,50) [2]", r,
+ testRegex("Ahern (50,50) [2]", url,
"XXX secondlife:///app/teleport/Ahern/50/50 XXX",
"secondlife:///app/teleport/Ahern/50/50");
- testRegex("Ahern (50)", r,
+ testRegex("Ahern (50)", url,
"XXX secondlife:///app/teleport/Ahern/50 XXX",
"secondlife:///app/teleport/Ahern/50");
- testRegex("Ahern", r,
+ testRegex("Ahern", url,
"XXX secondlife:///app/teleport/Ahern/ XXX",
"secondlife:///app/teleport/Ahern/");
- testRegex("Ahern teleport with title", r,
+ testRegex("Ahern teleport with title", url,
"XXX secondlife:///app/teleport/Ahern/50/50/50/?title=YOUR%20TITLE%20HERE! XXX",
"secondlife:///app/teleport/Ahern/50/50/50/?title=YOUR%20TITLE%20HERE!");
- testRegex("Ahern teleport with msg", r,
+ testRegex("Ahern teleport with msg", url,
"XXX secondlife:///app/teleport/Ahern/50/50/50/?msg=Your%20text%20here. XXX",
"secondlife:///app/teleport/Ahern/50/50/50/?msg=Your%20text%20here.");
// DEV-21577: In-world SLURLs containing "(" or ")" are not treated as a hyperlink in chat
- testRegex("Teleport with brackets", r,
+ testRegex("Teleport with brackets", url,
"XXX secondlife:///app/teleport/Burning%20Life%20(Hyper)/27/210/30 XXX",
"secondlife:///app/teleport/Burning%20Life%20(Hyper)/27/210/30");
// DEV-35459: SLURLs and teleport Links not parsed properly
- testRegex("Teleport url with quote", r,
+ testRegex("Teleport url with quote", url,
"XXX secondlife:///app/teleport/A'ksha%20Oasis/41/166/701 XXX",
- "secondlife:///app/teleport/A'ksha%20Oasis/41/166/701");
+ "secondlife:///app/teleport/A%27ksha%20Oasis/41/166/701");
}
template<> template<>
@@ -477,33 +470,32 @@ namespace tut
// test LLUrlEntrySL - general secondlife:// URLs
//
LLUrlEntrySL url;
- boost::regex r = url.getPattern();
- testRegex("no valid slapp [1]", r,
+ testRegex("no valid slapp [1]", url,
"http:///app/",
"");
- testRegex("valid slapp [1]", r,
+ testRegex("valid slapp [1]", url,
"secondlife:///app/",
"secondlife:///app/");
- testRegex("valid slapp [2]", r,
+ testRegex("valid slapp [2]", url,
"secondlife:///app/teleport/Ahern/50/50/50/",
"secondlife:///app/teleport/Ahern/50/50/50/");
- testRegex("valid slapp [3]", r,
+ testRegex("valid slapp [3]", url,
"secondlife:///app/foo",
"secondlife:///app/foo");
- testRegex("valid slapp [4]", r,
+ testRegex("valid slapp [4]", url,
"secondlife:///APP/foo?title=Hi%20There",
"secondlife:///APP/foo?title=Hi%20There");
- testRegex("valid slapp [5]", r,
+ testRegex("valid slapp [5]", url,
"secondlife://host/app/",
"secondlife://host/app/");
- testRegex("valid slapp [6]", r,
+ testRegex("valid slapp [6]", url,
"secondlife://host:8080/foo/bar",
"secondlife://host:8080/foo/bar");
}
@@ -515,35 +507,34 @@ namespace tut
// test LLUrlEntrySLLabel - general secondlife:// URLs with labels
//
LLUrlEntrySLLabel url;
- boost::regex r = url.getPattern();
- testRegex("invalid wiki url [1]", r,
+ testRegex("invalid wiki url [1]", url,
"[secondlife:///app/]",
"");
- testRegex("invalid wiki url [2]", r,
+ testRegex("invalid wiki url [2]", url,
"[secondlife:///app/",
"");
- testRegex("invalid wiki url [3]", r,
+ testRegex("invalid wiki url [3]", url,
"[secondlife:///app/ Label",
"");
- testRegex("agent slurl with label (spaces)", r,
+ testRegex("agent slurl with label (spaces)", url,
"[secondlife:///app/agent/0e346d8b-4433-4d66-a6b0-fd37083abc4c/about Text]",
- "[secondlife:///app/agent/0e346d8b-4433-4d66-a6b0-fd37083abc4c/about Text]");
+ "secondlife:///app/agent/0e346d8b-4433-4d66-a6b0-fd37083abc4c/about");
- testRegex("agent slurl with label (tabs)", r,
+ testRegex("agent slurl with label (tabs)", url,
"[secondlife:///app/agent/0e346d8b-4433-4d66-a6b0-fd37083abc4c/about\t Text]",
- "[secondlife:///app/agent/0e346d8b-4433-4d66-a6b0-fd37083abc4c/about\t Text]");
+ "secondlife:///app/agent/0e346d8b-4433-4d66-a6b0-fd37083abc4c/about");
- testRegex("agent slurl with label", r,
+ testRegex("agent slurl with label", url,
"[secondlife:///app/agent/0e346d8b-4433-4d66-a6b0-fd37083abc4c/about FirstName LastName]",
- "[secondlife:///app/agent/0e346d8b-4433-4d66-a6b0-fd37083abc4c/about FirstName LastName]");
+ "secondlife:///app/agent/0e346d8b-4433-4d66-a6b0-fd37083abc4c/about");
- testRegex("teleport slurl with label", r,
+ testRegex("teleport slurl with label", url,
"XXX [secondlife:///app/teleport/Ahern/50/50/50/ Teleport to Ahern] YYY",
- "[secondlife:///app/teleport/Ahern/50/50/50/ Teleport to Ahern]");
+ "secondlife:///app/teleport/Ahern/50/50/50/");
}
template<> template<>
@@ -553,70 +544,98 @@ namespace tut
// test LLUrlEntryHTTPNoProtocol - general URLs without a protocol
//
LLUrlEntryHTTPNoProtocol url;
- boost::regex r = url.getPattern();
- testRegex("naked .com URL", r,
+ testRegex("naked .com URL", url,
"see google.com",
- "google.com");
+ "http://google.com");
- testRegex("naked .org URL", r,
+ testRegex("naked .org URL", url,
"see en.wikipedia.org for details",
- "en.wikipedia.org");
+ "http://en.wikipedia.org");
- testRegex("naked .net URL", r,
+ testRegex("naked .net URL", url,
"example.net",
- "example.net");
+ "http://example.net");
- testRegex("naked .edu URL (2 instances)", r,
+ testRegex("naked .edu URL (2 instances)", url,
"MIT web site is at web.mit.edu and also www.mit.edu",
- "web.mit.edu");
+ "http://web.mit.edu");
- testRegex("don't match e-mail addresses", r,
+ testRegex("don't match e-mail addresses", url,
"test@lindenlab.com",
"");
- testRegex(".com URL with path", r,
+ testRegex(".com URL with path", url,
"see secondlife.com/status for grid status",
- "secondlife.com/status");
+ "http://secondlife.com/status");
- testRegex(".com URL with port", r,
+ testRegex(".com URL with port", url,
"secondlife.com:80",
- "secondlife.com:80");
+ "http://secondlife.com:80");
- testRegex(".com URL with port and path", r,
+ testRegex(".com URL with port and path", url,
"see secondlife.com:80/status",
- "secondlife.com:80/status");
+ "http://secondlife.com:80/status");
- testRegex("www.*.com URL with port and path", r,
+ testRegex("www.*.com URL with port and path", url,
"see www.secondlife.com:80/status",
- "www.secondlife.com:80/status");
+ "http://www.secondlife.com:80/status");
- testRegex("invalid .com URL [1]", r,
+ testRegex("invalid .com URL [1]", url,
"..com",
"");
- testRegex("invalid .com URL [2]", r,
+ testRegex("invalid .com URL [2]", url,
"you.come",
"");
- testRegex("invalid .com URL [3]", r,
+ testRegex("invalid .com URL [3]", url,
"recommended",
"");
- testRegex("invalid .edu URL", r,
+ testRegex("invalid .edu URL", url,
"hi there scheduled maitenance has begun",
"");
- testRegex("invalid .net URL", r,
+ testRegex("invalid .net URL", url,
"foo.netty",
"");
- testRegex("XML tags around URL [1]", r,
+ testRegex("XML tags around URL [1]", url,
"<foo>secondlife.com</foo>",
- "secondlife.com");
+ "http://secondlife.com");
- testRegex("XML tags around URL [2]", r,
+ testRegex("XML tags around URL [2]", url,
"<foo>secondlife.com/status?bar=1</foo>",
- "secondlife.com/status?bar=1");
+ "http://secondlife.com/status?bar=1");
+ }
+
+ template<> template<>
+ void object::test<12>()
+ {
+ //
+ // test LLUrlEntryNoLink - turn off hyperlinking
+ //
+ LLUrlEntryNoLink url;
+
+ testRegex("<nolink> [1]", url,
+ "<nolink>google.com</nolink>",
+ "google.com");
+
+ testRegex("<nolink> [2]", url,
+ "<nolink>google.com",
+ "");
+
+ testRegex("<nolink> [3]", url,
+ "google.com</nolink>",
+ "");
+
+ testRegex("<nolink> [4]", url,
+ "<nolink>Hello World</nolink>",
+ "Hello World");
+
+ testRegex("<nolink> [5]", url,
+ "<nolink>My Object</nolink>",
+ "My Object");
}
}
diff --git a/indra/newview/llchathistory.cpp b/indra/newview/llchathistory.cpp
index 581c210bd5..7c22ac9e36 100644
--- a/indra/newview/llchathistory.cpp
+++ b/indra/newview/llchathistory.cpp
@@ -579,19 +579,26 @@ void LLChatHistory::appendMessage(const LLChat& chat, const LLSD &args, const LL
url += "?name=" + chat.mFromName;
url += "&owner=" + args["owner_id"].asString();
- LLViewerRegion *region = LLWorld::getInstance()->getRegionFromPosAgent(chat.mPosAgent);
- if (region)
+ std::string slurl = args["slurl"].asString();
+ if (slurl.empty())
{
- S32 x, y, z;
- LLSLURL::globalPosToXYZ(LLVector3d(chat.mPosAgent), x, y, z);
- url += "&slurl=" + region->getName() + llformat("/%d/%d/%d", x, y, z);
+ LLViewerRegion *region = LLWorld::getInstance()->getRegionFromPosAgent(chat.mPosAgent);
+ if (region)
+ {
+ S32 x, y, z;
+ LLSLURL::globalPosToXYZ(LLVector3d(chat.mPosAgent), x, y, z);
+ slurl = region->getName() + llformat("/%d/%d/%d", x, y, z);
+ }
}
+ url += "&slurl=" + slurl;
// set the link for the object name to be the objectim SLapp
+ // (don't let object names with hyperlinks override our objectim Url)
LLStyle::Params link_params(style_params);
link_params.color.control = "HTMLLinkColor";
link_params.link_href = url;
- mEditor->appendText(chat.mFromName + delimiter, false, link_params);
+ mEditor->appendText("<nolink>" + chat.mFromName + "</nolink>" + delimiter,
+ false, link_params);
}
else if ( chat.mFromName != SYSTEM_FROM && chat.mFromID.notNull() )
{
diff --git a/indra/newview/llinspectremoteobject.cpp b/indra/newview/llinspectremoteobject.cpp
index 898f1cd9ac..66e4a1bf66 100644
--- a/indra/newview/llinspectremoteobject.cpp
+++ b/indra/newview/llinspectremoteobject.cpp
@@ -167,7 +167,8 @@ void LLInspectRemoteObject::nameCallback(const LLUUID& id, const std::string& fi
void LLInspectRemoteObject::update()
{
// show the object name as the inspector's title
- getChild<LLUICtrl>("object_name")->setValue(mName);
+ // (don't hyperlink URLs in object names)
+ getChild<LLUICtrl>("object_name")->setValue("<nolink>" + mName + "</nolink>");
// show the object's owner - click it to show profile
std::string owner = mOwner;
@@ -192,7 +193,7 @@ void LLInspectRemoteObject::update()
std::string url;
if (! mSLurl.empty())
{
- std::string url = "secondlife:///app/teleport/" + mSLurl;
+ url = "secondlife:///app/teleport/" + mSLurl;
}
getChild<LLUICtrl>("object_slurl")->setValue(url);
diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp
index b0952dd698..aa9d0f469d 100644
--- a/indra/newview/llviewermessage.cpp
+++ b/indra/newview/llviewermessage.cpp
@@ -2189,7 +2189,10 @@ void process_improved_im(LLMessageSystem *msg, void **user_data)
LLNearbyChat* nearby_chat = LLFloaterReg::getTypedInstance<LLNearbyChat>("nearby_chat", LLSD());
if(nearby_chat)
{
- nearby_chat->addMessage(chat);
+ LLSD args;
+ args["owner_id"] = from_id;
+ args["slurl"] = location;
+ nearby_chat->addMessage(chat, true, args);
}