Bug 1663947 - prevent the most common entities from appearing in event/task descriptions. r=darktrojan
This commit is contained in:
Родитель
a4025cbd42
Коммит
9b21c853ec
|
@ -369,18 +369,25 @@ var calview = {
|
|||
textToHtmlDocumentFragment(text, doc) {
|
||||
// Convert plain text to HTML. The main motivation here is to convert plain
|
||||
// text URLs into <a> tags (to linkify them).
|
||||
let textWithBreaks = text.replace(/\r?\n/g, "<br/>");
|
||||
let mode, html;
|
||||
text = text.replace(/\r?\n/g, "<br/>");
|
||||
// Resolve some of the most common entities.
|
||||
text = text.replace(/ /g, "\u00A0");
|
||||
text = text.replace(/©/g, "\u00A9");
|
||||
text = text.replace(/®/g, "\u00AE");
|
||||
text = text.replace(/–/g, "\u2013");
|
||||
text = text.replace(/—/g, "\u2014");
|
||||
text = text.replace(/€/g, "\u20AC");
|
||||
let html;
|
||||
try {
|
||||
// kGlyphSubstitution may lead to unexpected results when used in scanHTML.
|
||||
mode =
|
||||
let mode =
|
||||
Ci.mozITXTToHTMLConv.kStructPhrase |
|
||||
Ci.mozITXTToHTMLConv.kGlyphSubstitution |
|
||||
Ci.mozITXTToHTMLConv.kURLs;
|
||||
html = gTextToHtmlConverter.scanHTML(textWithBreaks, mode);
|
||||
html = gTextToHtmlConverter.scanHTML(text, mode);
|
||||
} catch (e) {
|
||||
mode = Ci.mozITXTToHTMLConv.kStructPhrase | Ci.mozITXTToHTMLConv.kURLs;
|
||||
html = gTextToHtmlConverter.scanHTML(textWithBreaks, mode);
|
||||
let mode = Ci.mozITXTToHTMLConv.kStructPhrase | Ci.mozITXTToHTMLConv.kURLs;
|
||||
html = gTextToHtmlConverter.scanHTML(text, mode);
|
||||
}
|
||||
|
||||
// Sanitize and convert the HTML into a document fragment.
|
||||
|
|
|
@ -262,6 +262,17 @@ add_task(async function createInvitationOverlay_test() {
|
|||
value: "Or we can try: ",
|
||||
},
|
||||
},
|
||||
{
|
||||
input: {
|
||||
description:
|
||||
'DESCRIPTION:Check <a href="http://example.com">example.com</a> — only 3 €\r\n',
|
||||
},
|
||||
expected: {
|
||||
node: "imipHtml-description-content",
|
||||
value:
|
||||
'Check <a xmlns="http://www.w3.org/1999/xhtml" href="http://example.com">example.com</a>\u00A0\u00A0\u2014 only 3 €',
|
||||
},
|
||||
},
|
||||
{
|
||||
input: { url: "URL:http://www.example.org/event.ics\r\n" },
|
||||
expected: {
|
||||
|
|
Загрузка…
Ссылка в новой задаче