Force replacing registered urls everywhere that's not from another user
I think I covered all my bases: Local Chat, IMs/Group/Conference Chats Script Dialogs Group Notices There are a few others maybe, like notifications EMs can spawn but if those are intentionally tricking people, grid owners should be informed.
This commit is contained in:
@@ -4262,7 +4262,7 @@ void LLTextEditor::appendColoredText(const std::string &new_text,
|
|||||||
static LLTrace::BlockTimerStatHandle FTM_APPEND_TEXT("Append Text");
|
static LLTrace::BlockTimerStatHandle FTM_APPEND_TEXT("Append Text");
|
||||||
|
|
||||||
void LLTextEditor::appendText(const std::string &new_text, bool allow_undo, bool prepend_newline,
|
void LLTextEditor::appendText(const std::string &new_text, bool allow_undo, bool prepend_newline,
|
||||||
const LLStyleSP style)
|
const LLStyleSP style, bool force_replace_links)
|
||||||
{
|
{
|
||||||
LL_RECORD_BLOCK_TIME(FTM_APPEND_TEXT);
|
LL_RECORD_BLOCK_TIME(FTM_APPEND_TEXT);
|
||||||
if (new_text.empty())
|
if (new_text.empty())
|
||||||
@@ -4280,10 +4280,11 @@ void LLTextEditor::appendText(const std::string &new_text, bool allow_undo, bool
|
|||||||
static LLTrace::BlockTimerStatHandle FTM_PARSE_HTML("Parse HTML");
|
static LLTrace::BlockTimerStatHandle FTM_PARSE_HTML("Parse HTML");
|
||||||
|
|
||||||
// Appends new text to end of document
|
// Appends new text to end of document
|
||||||
void LLTextEditor::appendTextImpl(const std::string &new_text, const LLStyleSP style)
|
void LLTextEditor::appendTextImpl(const std::string &new_text, const LLStyleSP style, bool force_replace_links)
|
||||||
{
|
{
|
||||||
std::string text = new_text;
|
std::string text = new_text;
|
||||||
static LLUICachedControl<bool> replace_links("SinguReplaceLinks");
|
static const LLUICachedControl<bool> replace_links("SinguReplaceLinks");
|
||||||
|
force_replace_links = force_replace_links || replace_links;
|
||||||
bool is_link = style && style->isLink(); // Don't search for URLs inside a link segment (STORM-358).
|
bool is_link = style && style->isLink(); // Don't search for URLs inside a link segment (STORM-358).
|
||||||
|
|
||||||
S32 part = (S32)LLTextParser::WHOLE;
|
S32 part = (S32)LLTextParser::WHOLE;
|
||||||
@@ -4309,8 +4310,8 @@ void LLTextEditor::appendTextImpl(const std::string &new_text, const LLStyleSP s
|
|||||||
if (mLinkColor) link_style->setColor(*mLinkColor);
|
if (mLinkColor) link_style->setColor(*mLinkColor);
|
||||||
appendAndHighlightText(link, part, link_style, true/*match.underlineOnHoverOnly()*/);
|
appendAndHighlightText(link, part, link_style, true/*match.underlineOnHoverOnly()*/);
|
||||||
};
|
};
|
||||||
while (!text.empty() && LLUrlRegistry::instance().findUrl(text, match,
|
const auto&& cb = force_replace_links ? boost::bind(&LLTextEditor::replaceUrl, this, _1, _2, _3) : LLUrlLabelCallback::slot_function_type();
|
||||||
boost::bind(&LLTextEditor::replaceUrl, this, _1, _2, _3)))
|
while (!text.empty() && LLUrlRegistry::instance().findUrl(text, match, cb))
|
||||||
{
|
{
|
||||||
start = match.getStart();
|
start = match.getStart();
|
||||||
end = match.getEnd()+1;
|
end = match.getEnd()+1;
|
||||||
@@ -4332,7 +4333,7 @@ void LLTextEditor::appendTextImpl(const std::string &new_text, const LLStyleSP s
|
|||||||
|
|
||||||
auto url = match.getUrl();
|
auto url = match.getUrl();
|
||||||
const auto& label = match.getLabel();
|
const auto& label = match.getLabel();
|
||||||
if (replace_links || url == label)
|
if (force_replace_links || replace_links || url == label)
|
||||||
{
|
{
|
||||||
// add icon before url if need
|
// add icon before url if need
|
||||||
/* Singu TODO: Icons next to links?
|
/* Singu TODO: Icons next to links?
|
||||||
@@ -4371,7 +4372,7 @@ void LLTextEditor::appendTextImpl(const std::string &new_text, const LLStyleSP s
|
|||||||
}
|
}
|
||||||
}*/
|
}*/
|
||||||
}
|
}
|
||||||
else if (!replace_links) // Still link the link itself
|
else // Still link the link itself
|
||||||
{
|
{
|
||||||
const auto pos = text.find(url);
|
const auto pos = text.find(url);
|
||||||
bool fallback(pos == std::string::npos); // In special cases like no protocol and brackets
|
bool fallback(pos == std::string::npos); // In special cases like no protocol and brackets
|
||||||
@@ -4454,9 +4455,6 @@ void LLTextEditor::replaceUrl(const std::string &url,
|
|||||||
const std::string &label,
|
const std::string &label,
|
||||||
const std::string &icon)
|
const std::string &icon)
|
||||||
{
|
{
|
||||||
static LLUICachedControl<bool> replace_links("SinguReplaceLinks");
|
|
||||||
if (!replace_links) return;
|
|
||||||
|
|
||||||
// get the full (wide) text for the editor so we can change it
|
// get the full (wide) text for the editor so we can change it
|
||||||
LLWString text = getWText();
|
LLWString text = getWText();
|
||||||
LLWString wlabel = utf8str_to_wstring(label);
|
LLWString wlabel = utf8str_to_wstring(label);
|
||||||
|
|||||||
@@ -181,8 +181,8 @@ public:
|
|||||||
void insertText(const std::string &text, BOOL deleteSelection = TRUE);
|
void insertText(const std::string &text, BOOL deleteSelection = TRUE);
|
||||||
// appends text at end
|
// appends text at end
|
||||||
void appendText(const std::string &wtext, bool allow_undo, bool prepend_newline,
|
void appendText(const std::string &wtext, bool allow_undo, bool prepend_newline,
|
||||||
const LLStyleSP stylep = NULL);
|
const LLStyleSP stylep = NULL, bool force_replace_links = true);
|
||||||
void appendTextImpl(const std::string& new_text, const LLStyleSP style);
|
void appendTextImpl(const std::string& new_text, const LLStyleSP style, bool force_replace_links = true);
|
||||||
|
|
||||||
void setLastSegmentToolTip(const std::string& tooltip);
|
void setLastSegmentToolTip(const std::string& tooltip);
|
||||||
|
|
||||||
|
|||||||
@@ -217,14 +217,14 @@ void add_timestamped_line(LLViewerTextEditor* edit, LLChat chat, const LLColor4&
|
|||||||
line = line.substr(chat.mFromName.length());
|
line = line.substr(chat.mFromName.length());
|
||||||
LLStyleSP sourceStyle = LLStyleMap::instance().lookup(chat.mFromID, chat.mURL);
|
LLStyleSP sourceStyle = LLStyleMap::instance().lookup(chat.mFromID, chat.mURL);
|
||||||
sourceStyle->mItalic = is_irc;
|
sourceStyle->mItalic = is_irc;
|
||||||
edit->appendText(chat.mFromName, false, prepend_newline, sourceStyle);
|
edit->appendText(chat.mFromName, false, prepend_newline, sourceStyle, false);
|
||||||
prepend_newline = false;
|
prepend_newline = false;
|
||||||
}
|
}
|
||||||
LLStyleSP style(new LLStyle);
|
LLStyleSP style(new LLStyle);
|
||||||
style->setColor(color);
|
style->setColor(color);
|
||||||
style->mItalic = is_irc;
|
style->mItalic = is_irc;
|
||||||
style->mBold = chat.mChatType == CHAT_TYPE_SHOUT;
|
style->mBold = chat.mChatType == CHAT_TYPE_SHOUT;
|
||||||
edit->appendText(line, false, prepend_newline, style);
|
edit->appendText(line, false, prepend_newline, style, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void log_chat_text(const LLChat& chat)
|
void log_chat_text(const LLChat& chat)
|
||||||
|
|||||||
@@ -175,11 +175,12 @@ LLGroupNotifyBox::LLGroupNotifyBox(const std::string& subject,
|
|||||||
|
|
||||||
static const LLStyleSP headerstyle(new LLStyle(true,LLColor4::black,"SansSerifBig"));
|
static const LLStyleSP headerstyle(new LLStyle(true,LLColor4::black,"SansSerifBig"));
|
||||||
static const LLStyleSP datestyle(new LLStyle(true,LLColor4::black,"serif"));
|
static const LLStyleSP datestyle(new LLStyle(true,LLColor4::black,"serif"));
|
||||||
|
static const LLStyleSP msgstyle(new LLStyle(true, LLColor4::grey4, LLStringUtil::null));
|
||||||
|
|
||||||
text->appendText(subject + '\n',false,false,headerstyle);
|
text->appendText(subject + '\n',false,false,headerstyle,false);
|
||||||
|
|
||||||
text->appendText(time_buf,false,false,datestyle);
|
text->appendText(time_buf,false,false,datestyle,false);
|
||||||
text->appendColoredText(std::string(" \n\n") + message,false,false,LLColor4::grey4);
|
text->appendText(std::string(" \n\n") + message,false,false,msgstyle,false);
|
||||||
|
|
||||||
LLColor4 semi_transparent(1.0f,1.0f,1.0f,0.8f);
|
LLColor4 semi_transparent(1.0f,1.0f,1.0f,0.8f);
|
||||||
text->setCursor(0,0);
|
text->setCursor(0,0);
|
||||||
|
|||||||
@@ -804,7 +804,7 @@ void LLFloaterIMPanel::addHistoryLine(const std::string &utf8msg, LLColor4 incol
|
|||||||
// Convert the name to a hotlink and add to message.
|
// Convert the name to a hotlink and add to message.
|
||||||
LLStyleSP source_style = LLStyleMap::instance().lookupAgent(source);
|
LLStyleSP source_style = LLStyleMap::instance().lookupAgent(source);
|
||||||
source_style->mItalic = is_irc;
|
source_style->mItalic = is_irc;
|
||||||
mHistoryEditor->appendText(show_name,false,prepend_newline,source_style);
|
mHistoryEditor->appendText(show_name,false,prepend_newline,source_style, false);
|
||||||
}
|
}
|
||||||
prepend_newline = false;
|
prepend_newline = false;
|
||||||
}
|
}
|
||||||
@@ -815,7 +815,7 @@ void LLFloaterIMPanel::addHistoryLine(const std::string &utf8msg, LLColor4 incol
|
|||||||
style->setColor(incolor);
|
style->setColor(incolor);
|
||||||
style->mItalic = is_irc;
|
style->mItalic = is_irc;
|
||||||
style->mBold = from_user && gSavedSettings.getBOOL("SingularityBoldGroupModerator") && isModerator(source);
|
style->mBold = from_user && gSavedSettings.getBOOL("SingularityBoldGroupModerator") && isModerator(source);
|
||||||
mHistoryEditor->appendText(utf8msg, false, prepend_newline, style);
|
mHistoryEditor->appendText(utf8msg, false, prepend_newline, style, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (log_to_file
|
if (log_to_file
|
||||||
|
|||||||
@@ -249,7 +249,7 @@ LLNotifyBox::LLNotifyBox(LLNotificationPtr notification)
|
|||||||
if (!mIsCaution) // We could do some extra color math here to determine if bg's too close to link color, but let's just cross with the link color instead
|
if (!mIsCaution) // We could do some extra color math here to determine if bg's too close to link color, but let's just cross with the link color instead
|
||||||
text->setLinkColor(new LLColor4(lerp(text_color, gSavedSettings.getColor4("HTMLLinkColor"), 0.4)));
|
text->setLinkColor(new LLColor4(lerp(text_color, gSavedSettings.getColor4("HTMLLinkColor"), 0.4)));
|
||||||
text->setTabStop(FALSE); // can't tab to it (may be a problem for scrolling via keyboard)
|
text->setTabStop(FALSE); // can't tab to it (may be a problem for scrolling via keyboard)
|
||||||
text->setText(message); // Now we can set the text, since colors have been set.
|
text->appendText(message,false,false,nullptr,!layout_script_dialog); // Now we can set the text, since colors have been set.
|
||||||
addChild(text);
|
addChild(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user