Skip to content
Snippets Groups Projects
Commit 25547d32 authored by Mnikolenko ProductEngine's avatar Mnikolenko ProductEngine
Browse files

MAINT-4210 FIXED Don't try to replace wiki-link with label if it's not...

MAINT-4210 FIXED Don't try to replace wiki-link with label if it's not correct(contains url in label part).
parent e8adc1d0
No related branches found
No related tags found
No related merge requests found
...@@ -178,6 +178,12 @@ bool LLUrlEntryBase::isLinkDisabled() const ...@@ -178,6 +178,12 @@ bool LLUrlEntryBase::isLinkDisabled() const
return globally_disabled; return globally_disabled;
} }
bool LLUrlEntryBase::isWikiLinkCorrect(std::string url)
{
std::string label = getLabelFromWikiLink(url);
return (LLUrlRegistry::instance().hasUrl(label)) ? false : true;
}
static std::string getStringAfterToken(const std::string str, const std::string token) static std::string getStringAfterToken(const std::string str, const std::string token)
{ {
size_t pos = str.find(token); size_t pos = str.find(token);
......
...@@ -100,6 +100,8 @@ class LLUrlEntryBase ...@@ -100,6 +100,8 @@ class LLUrlEntryBase
bool isLinkDisabled() const; bool isLinkDisabled() const;
bool isWikiLinkCorrect(std::string url);
protected: protected:
std::string getIDStringFromUrl(const std::string &url) const; std::string getIDStringFromUrl(const std::string &url) const;
std::string escapeUrl(const std::string &url) const; std::string escapeUrl(const std::string &url) const;
......
...@@ -45,7 +45,8 @@ LLUrlRegistry::LLUrlRegistry() ...@@ -45,7 +45,8 @@ LLUrlRegistry::LLUrlRegistry()
registerUrl(mUrlEntryIcon); registerUrl(mUrlEntryIcon);
registerUrl(new LLUrlEntrySLURL()); registerUrl(new LLUrlEntrySLURL());
registerUrl(new LLUrlEntryHTTP()); registerUrl(new LLUrlEntryHTTP());
registerUrl(new LLUrlEntryHTTPLabel()); mUrlEntryHTTPLabel = new LLUrlEntryHTTPLabel();
registerUrl(mUrlEntryHTTPLabel);
registerUrl(new LLUrlEntryAgentCompleteName()); registerUrl(new LLUrlEntryAgentCompleteName());
registerUrl(new LLUrlEntryAgentDisplayName()); registerUrl(new LLUrlEntryAgentDisplayName());
registerUrl(new LLUrlEntryAgentUserName()); registerUrl(new LLUrlEntryAgentUserName());
...@@ -64,7 +65,8 @@ LLUrlRegistry::LLUrlRegistry() ...@@ -64,7 +65,8 @@ LLUrlRegistry::LLUrlRegistry()
//LLUrlEntrySL and LLUrlEntrySLLabel have more common pattern, //LLUrlEntrySL and LLUrlEntrySLLabel have more common pattern,
//so it should be registered in the end of list //so it should be registered in the end of list
registerUrl(new LLUrlEntrySL()); registerUrl(new LLUrlEntrySL());
registerUrl(new LLUrlEntrySLLabel()); mUrlEntrySLLabel = new LLUrlEntrySLLabel();
registerUrl(mUrlEntrySLLabel);
// most common pattern is a URL without any protocol, // most common pattern is a URL without any protocol,
// e.g., "secondlife.com" // e.g., "secondlife.com"
registerUrl(new LLUrlEntryHTTPNoProtocol()); registerUrl(new LLUrlEntryHTTPNoProtocol());
...@@ -128,6 +130,11 @@ static bool matchRegex(const char *text, boost::regex regex, U32 &start, U32 &en ...@@ -128,6 +130,11 @@ static bool matchRegex(const char *text, boost::regex regex, U32 &start, U32 &en
end--; end--;
} }
else if (text[end] == ']' && std::string(text+start, end-start).find('[') == std::string::npos)
{
end--;
}
return true; return true;
} }
...@@ -175,6 +182,15 @@ bool LLUrlRegistry::findUrl(const std::string &text, LLUrlMatch &match, const LL ...@@ -175,6 +182,15 @@ bool LLUrlRegistry::findUrl(const std::string &text, LLUrlMatch &match, const LL
// does this match occur in the string before any other match // does this match occur in the string before any other match
if (start < match_start || match_entry == NULL) if (start < match_start || match_entry == NULL)
{ {
if((mUrlEntryHTTPLabel == *it) || (mUrlEntrySLLabel == *it))
{
if(url_entry && !url_entry->isWikiLinkCorrect(text.substr(start, end - start + 1)))
{
continue;
}
}
match_start = start; match_start = start;
match_end = end; match_end = end;
match_entry = url_entry; match_entry = url_entry;
......
...@@ -94,6 +94,8 @@ class LLUrlRegistry : public LLSingleton<LLUrlRegistry> ...@@ -94,6 +94,8 @@ class LLUrlRegistry : public LLSingleton<LLUrlRegistry>
std::vector<LLUrlEntryBase *> mUrlEntry; std::vector<LLUrlEntryBase *> mUrlEntry;
LLUrlEntryBase* mUrlEntryIcon; LLUrlEntryBase* mUrlEntryIcon;
LLUrlEntryBase* mUrlEntryHTTPLabel;
LLUrlEntryBase* mUrlEntrySLLabel;
}; };
#endif #endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment