summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreyL ProductEngine <andreylproductengine@lindenlab.com>2015-07-15 23:58:56 +0300
committerAndreyL ProductEngine <andreylproductengine@lindenlab.com>2015-07-15 23:58:56 +0300
commit62c748936c42451d4a17c5321d804111203a9e4f (patch)
tree2da6873c24a851d1c65a5a56630d137672573eba
parent222a8b101c26472156dad950b1c48fdeb579ad60 (diff)
MAINT-5019: Buildfix - added a tests for emails, improved handling of URLs starting with www.
-rwxr-xr-xindra/llui/llurlentry.cpp2
-rwxr-xr-xindra/llui/tests/llurlentry_test.cpp76
2 files changed, 56 insertions, 22 deletions
diff --git a/indra/llui/llurlentry.cpp b/indra/llui/llurlentry.cpp
index 95f931de0a..91d655ee9e 100755
--- a/indra/llui/llurlentry.cpp
+++ b/indra/llui/llurlentry.cpp
@@ -293,7 +293,7 @@ std::string LLUrlEntryHTTPLabel::getUrl(const std::string &string) const
LLUrlEntryHTTPNoProtocol::LLUrlEntryHTTPNoProtocol()
: LLUrlEntryBase()
{
- mPattern = boost::regex("\\bwww\\.\\S+\\.\\S+", // i.e. www.FOO.BAR
+ mPattern = boost::regex("\\bwww\\.\\S+\\.([^\\s<]*)?\\b", // i.e. www.FOO.BAR
boost::regex::perl|boost::regex::icase);
mMenuName = "menu_url_http.xml";
mTooltip = LLTrans::getString("TooltipHttpUrl");
diff --git a/indra/llui/tests/llurlentry_test.cpp b/indra/llui/tests/llurlentry_test.cpp
index 15f2354552..a4ab6943b8 100755
--- a/indra/llui/tests/llurlentry_test.cpp
+++ b/indra/llui/tests/llurlentry_test.cpp
@@ -653,45 +653,45 @@ namespace tut
void object::test<11>()
{
//
- // test LLUrlEntryHTTPNoProtocol - general URLs without a protocol
+ // test LLUrlEntryHTTPNoProtocol - general URLs without a protocol, starting with "www." prefix (MAINT-5019)
//
LLUrlEntryHTTPNoProtocol url;
testRegex("naked .com URL", url,
"see google.com",
- "http://google.com");
+ "");
testRegex("naked .org URL", url,
"see en.wikipedia.org for details",
- "http://en.wikipedia.org");
+ "");
testRegex("naked .net URL", url,
"example.net",
- "http://example.net");
+ "");
- testRegex("naked .edu URL (2 instances)", url,
+ testRegex("naked .edu URL (2 instances), .www prefix", url,
"MIT web site is at web.mit.edu and also www.mit.edu",
- "http://web.mit.edu");
+ "http://www.mit.edu");
testRegex("don't match e-mail addresses", url,
"test@lindenlab.com",
"");
- testRegex(".com URL with path", url,
- "see secondlife.com/status for grid status",
- "http://secondlife.com/status");
+ testRegex("www.test.com URL with path", url,
+ "see www.test.com/status for grid status",
+ "http://www.test.com/status");
- testRegex(".com URL with port", url,
- "secondlife.com:80",
- "http://secondlife.com:80");
+ testRegex("www.test.com URL with port", url,
+ "www.test.com:80",
+ "http://www.test.com:80");
- testRegex(".com URL with port and path", url,
- "see secondlife.com:80/status",
- "http://secondlife.com:80/status");
+ testRegex("www.test.com URL with port and path", url,
+ "see www.test.com:80/status",
+ "http://www.test.com:80/status");
testRegex("www.*.com URL with port and path", url,
- "see www.secondlife.com:80/status",
- "http://www.secondlife.com:80/status");
+ "see www.test.com:80/status",
+ "http://www.test.com:80/status");
testRegex("invalid .com URL [1]", url,
"..com",
@@ -714,12 +714,12 @@ namespace tut
"");
testRegex("XML tags around URL [1]", url,
- "<foo>secondlife.com</foo>",
- "http://secondlife.com");
+ "<foo>www.test.com</foo>",
+ "http://www.test.com");
testRegex("XML tags around URL [2]", url,
- "<foo>secondlife.com/status?bar=1</foo>",
- "http://secondlife.com/status?bar=1");
+ "<foo>www.test.com/status?bar=1</foo>",
+ "http://www.test.com/status?bar=1");
}
template<> template<>
@@ -860,4 +860,38 @@ namespace tut
"secondlife:///app/region/Product%20Engine",
"Product Engine");
}
+
+ template<> template<>
+ void object::test<14>()
+ {
+ //
+ // test LLUrlEntryemail - general emails
+ //
+ LLUrlEntryEmail url;
+
+ // Regex tests.
+ testRegex("match e-mail addresses", url,
+ "test@lindenlab.com",
+ "mailto:test@lindenlab.com");
+
+ testRegex("match e-mail addresses with mailto: prefix", url,
+ "mailto:test@lindenlab.com",
+ "mailto:test@lindenlab.com");
+
+ testRegex("match e-mail addresses with different domains", url,
+ "test@foo.org.us",
+ "mailto:test@foo.org.us");
+
+ testRegex("match e-mail addresses with different domains", url,
+ "test@foo.bar",
+ "mailto:test@foo.bar");
+
+ testRegex("don't match incorrect e-mail addresses", url,
+ "test @foo.com",
+ "");
+
+ testRegex("don't match incorrect e-mail addresses", url,
+ "test@ foo.com",
+ "");
+ }
}