diff options
author | Martin Reddy <lynx@lindenlab.com> | 2009-09-22 18:00:16 +0000 |
---|---|---|
committer | Martin Reddy <lynx@lindenlab.com> | 2009-09-22 18:00:16 +0000 |
commit | 12762053e5aff372a9f8d473c71aa81e805bb474 (patch) | |
tree | c2c29e3b178cc9c51b99bd94d2f478e96d8a7d30 /indra/llui/tests/llurlentry_test.cpp | |
parent | be41bf82c6325fc45c7c6474645f384479e27091 (diff) |
EXT-944 EXT-1026: converted the LLUrlRegistry::findUrl() method to
work on an LLWString instead of a std::string, so that we don't have
to worry about character offsets for variable-length-encoded UTF-8
strings.
This was causing crashes whenever we would try to show a textbox with
a URL and foreign characters (> 1 byte chars). Damn, I suck!
Diffstat (limited to 'indra/llui/tests/llurlentry_test.cpp')
-rw-r--r-- | indra/llui/tests/llurlentry_test.cpp | 34 |
1 files changed, 18 insertions, 16 deletions
diff --git a/indra/llui/tests/llurlentry_test.cpp b/indra/llui/tests/llurlentry_test.cpp index 1e7a0f7f2c..89a80f1e73 100644 --- a/indra/llui/tests/llurlentry_test.cpp +++ b/indra/llui/tests/llurlentry_test.cpp @@ -44,17 +44,19 @@ namespace namespace tut { - void testRegex(const std::string &testname, boost::regex regex, + void testRegex(const std::string &testname, boost::wregex regex, const char *text, const std::string &expected) { std::string url = ""; - boost::cmatch result; - bool found = boost::regex_search(text, result, regex); + boost::wcmatch result; + LLWString wtext = utf8str_to_wstring(text); + const wchar_t *wctext = wtext.c_str(); + bool found = boost::regex_search(wctext, result, regex); if (found) { - 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); + S32 start = static_cast<U32>(result[0].first - wctext); + S32 end = static_cast<U32>(result[0].second - wctext); + url = wstring_to_utf8str(wtext.substr(start, end-start)); } ensure_equals(testname, url, expected); } @@ -66,7 +68,7 @@ namespace tut // test LLUrlEntryHTTP - standard http Urls // LLUrlEntryHTTP url; - boost::regex r = url.getPattern(); + boost::wregex r = url.getPattern(); testRegex("no valid url", r, "htp://slurl.com/", @@ -145,7 +147,7 @@ namespace tut // test LLUrlEntryHTTPLabel - wiki-style http Urls with labels // LLUrlEntryHTTPLabel url; - boost::regex r = url.getPattern(); + boost::wregex r = url.getPattern(); testRegex("invalid wiki url [1]", r, "[http://www.example.org]", @@ -187,7 +189,7 @@ namespace tut // test LLUrlEntrySLURL - second life URLs // LLUrlEntrySLURL url; - boost::regex r = url.getPattern(); + boost::wregex r = url.getPattern(); testRegex("no valid slurl [1]", r, "htp://slurl.com/secondlife/Ahern/50/50/50/", @@ -259,7 +261,7 @@ namespace tut // test LLUrlEntryAgent - secondlife://app/agent Urls // LLUrlEntryAgent url; - boost::regex r = url.getPattern(); + boost::wregex r = url.getPattern(); testRegex("Invalid Agent Url", r, "secondlife:///app/agent/0e346d8b-4433-4d66-XXXX-fd37083abc4c/about", @@ -285,7 +287,7 @@ namespace tut // test LLUrlEntryGroup - secondlife://app/group Urls // LLUrlEntryGroup url; - boost::regex r = url.getPattern(); + boost::wregex r = url.getPattern(); testRegex("Invalid Group Url", r, "secondlife:///app/group/00005ff3-4044-c79f-XXXX-fb28ae0df991/about", @@ -311,7 +313,7 @@ namespace tut // test LLUrlEntryPlace - secondlife://<location> URLs // LLUrlEntryPlace url; - boost::regex r = url.getPattern(); + boost::wregex r = url.getPattern(); testRegex("no valid slurl [1]", r, "secondlife://Ahern/FOO/50/", @@ -359,7 +361,7 @@ namespace tut // test LLUrlEntryParcel - secondlife://app/parcel Urls // LLUrlEntryParcel url; - boost::regex r = url.getPattern(); + boost::wregex r = url.getPattern(); testRegex("Invalid Classified Url", r, "secondlife:///app/parcel/0000060e-4b39-e00b-XXXX-d98b1934e3a8/about", @@ -384,7 +386,7 @@ namespace tut // test LLUrlEntryTeleport - secondlife://app/teleport URLs // LLUrlEntryTeleport url; - boost::regex r = url.getPattern(); + boost::wregex r = url.getPattern(); testRegex("no valid teleport [1]", r, "http://slurl.com/secondlife/Ahern/50/50/50/", @@ -460,7 +462,7 @@ namespace tut // test LLUrlEntrySL - general secondlife:// URLs // LLUrlEntrySL url; - boost::regex r = url.getPattern(); + boost::wregex r = url.getPattern(); testRegex("no valid slapp [1]", r, "http:///app/", @@ -498,7 +500,7 @@ namespace tut // test LLUrlEntrySLLabel - general secondlife:// URLs with labels // LLUrlEntrySLLabel url; - boost::regex r = url.getPattern(); + boost::wregex r = url.getPattern(); testRegex("invalid wiki url [1]", r, "[secondlife:///app/]", |