Bug 1644024 - Properly escape HTML in topics. r=khushil DONTBUILD

This commit is contained in:
Patrick Cloke 2020-06-27 11:54:03 +03:00
Родитель ebe8b9da58
Коммит d5032404dd
2 изменённых файлов: 17 добавлений и 3 удалений

Просмотреть файл

@ -31,6 +31,11 @@ XPCOMUtils.defineLazyGetter(this, "_", () =>
l10nHelper("chrome://chat/locale/conversations.properties")
);
XPCOMUtils.defineLazyGetter(this, "TXTToHTML", function() {
let cs = Cc["@mozilla.org/txttohtmlconv;1"].getService(Ci.mozITXTToHTMLConv);
return aTXT => cs.scanTXT(aTXT, cs.kEntities);
});
var GenericAccountPrototype = {
__proto__: ClassInfo("prplIAccount", "generic account object"),
get wrappedJSObject() {
@ -764,6 +769,15 @@ var GenericConvChatPrototype = {
get topicSetter() {
return this._topicSetter;
},
/**
* Set the topic of a conversation.
*
* @param {string} aTopic - The new topic. If an update message is sent to
* the conversation, this will be HTML escaped before being sent.
* @param {string} aTopicSetter - The user who last modified the topic.
* @param {string} aQuiet - If false, a message notifying about the topic
* change will be sent to the conversation.
*/
setTopic(aTopic, aTopicSetter, aQuiet) {
// Only change the topic if the topic and/or topic setter has changed.
if (
@ -786,14 +800,14 @@ var GenericConvChatPrototype = {
let message;
if (aTopicSetter) {
if (aTopic) {
message = _("topicChanged", aTopicSetter, aTopic);
message = _("topicChanged", aTopicSetter, TXTToHTML(aTopic));
} else {
message = _("topicCleared", aTopicSetter);
}
} else {
aTopicSetter = null;
if (aTopic) {
message = _("topicSet", this.name, aTopic);
message = _("topicSet", this.name, TXTToHTML(aTopic));
} else {
message = _("topicNotSet", this.name);
}

Просмотреть файл

@ -55,7 +55,7 @@ var CTCP_TAGS_EXP = new RegExp("[" + Object.keys(CTCP_TAGS).join("") + "]");
// Remove all CTCP formatting characters.
function ctcpFormatToText(aString) {
let next,
input = TXTToHTML(aString),
input = aString,
output = "",
length;