Allow bare minimum urls in [url text] syntax

This commit is contained in:
Lirusaito
2019-04-19 20:07:46 -04:00
parent 564410ac7e
commit 8ef3e923e8

View File

@@ -41,6 +41,7 @@
//#include "lluicolortable.h" //#include "lluicolortable.h"
#include "message.h" #include "message.h"
#include <boost/algorithm/string.hpp>
#include <boost/format.hpp> // <alchemy/> #include <boost/format.hpp> // <alchemy/>
#define APP_HEADER_REGEX "((((x-grid-info://)|(x-grid-location-info://))[-\\w\\.]+(:\\d+)?/app)|(secondlife:///app))" #define APP_HEADER_REGEX "((((x-grid-info://)|(x-grid-location-info://))[-\\w\\.]+(:\\d+)?/app)|(secondlife:///app))"
@@ -120,11 +121,11 @@ std::string LLUrlEntryBase::getLabelFromWikiLink(const std::string &url) const
size_t start = 0; size_t start = 0;
while (! isspace(text[start])) while (! isspace(text[start]))
{ {
start++; ++start;
} }
while (text[start] == ' ' || text[start] == '\t') while (text[start] == ' ' || text[start] == '\t')
{ {
start++; ++start;
} }
return unescapeUrl(url.substr(start, url.size()-start-1)); return unescapeUrl(url.substr(start, url.size()-start-1));
} }
@@ -136,7 +137,7 @@ std::string LLUrlEntryBase::getUrlFromWikiLink(const std::string &string) const
size_t end = 0; size_t end = 0;
while (! isspace(text[end])) while (! isspace(text[end]))
{ {
end++; ++end;
} }
return escapeUrl(string.substr(1, end-1)); return escapeUrl(string.substr(1, end-1));
} }
@@ -273,7 +274,7 @@ std::string LLUrlEntryHTTP::getTooltip(const std::string &url) const
// //
LLUrlEntryHTTPLabel::LLUrlEntryHTTPLabel() LLUrlEntryHTTPLabel::LLUrlEntryHTTPLabel()
{ {
mPattern = boost::regex("\\[https?://\\S+[ \t]+[^\\]]+\\]", mPattern = boost::regex("\\[(https?://\\S+|\\S+\\.([^\\s<]*)?)[ \t]+[^\\]]+\\]",
boost::regex::perl|boost::regex::icase); boost::regex::perl|boost::regex::icase);
mMenuName = "menu_url_http.xml"; mMenuName = "menu_url_http.xml";
mTooltip = LLTrans::getString("TooltipHttpUrl"); mTooltip = LLTrans::getString("TooltipHttpUrl");
@@ -292,7 +293,10 @@ std::string LLUrlEntryHTTPLabel::getTooltip(const std::string &string) const
std::string LLUrlEntryHTTPLabel::getUrl(const std::string &string) const std::string LLUrlEntryHTTPLabel::getUrl(const std::string &string) const
{ {
return getUrlFromWikiLink(string); auto url = getUrlFromWikiLink(string);
if (!boost::istarts_with(url, "http"))
return "http://" + url;
return url;
} }
// //