You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/xml.lua2p
+8-7Lines changed: 8 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -91,8 +91,8 @@ local HTML_END_TAG_PATTERNS_FOR_TAGS_WITH_UNENCODED_CONTENTS = {
91
91
92
92
93
93
local xml = {
94
-
htmlAllowNoAttributeValue = true, -- @Doc (Maybe this should be an argument for toHtml()?)
95
-
htmlScrambleEmailAddresses = true, -- @Doc (Maybe this should be an argument for toHtml()?)
94
+
htmlAllowNoAttributeValue = true, -- @Cleanup: Maybe this should actually be an argument for toHtml()?
95
+
htmlScrambleEmailAddresses = true, -- @Cleanup: Maybe this should actually be an argument for toHtml()?
96
96
}
97
97
xml.__index = xml
98
98
@@ -528,7 +528,7 @@ local function parseElementContents(s, pos, pathForError, el, isHtml, isTop)
528
528
elseif s:find("^&", pos) then
529
529
if isTop then fileError(pathForError, s, posOffsetForError+pos, "Invalid data outside root element.") end
530
530
531
-
pos = _decodeEntities(s, pos,s, 0,pathForError, isHtml, el, true)
531
+
pos = _decodeEntities(s, pos,s, 0,pathForError, isHtml, el, true)
532
532
533
533
-- Text.
534
534
else
@@ -1304,6 +1304,7 @@ local function nodeToHtml(buffer, node, encodeTextAsEmail)
1304
1304
1305
1305
local tagName = el.tag -- (Don't call :lower() because that may make HTML_XML_ENTRY_TAGS[tagName] true and we end up in a weird situation. Only normalize when parsing!)
1306
1306
local allowNoAttrValue = xml.htmlAllowNoAttributeValue
1307
+
local scrambleEmails = xml.htmlScrambleEmailAddresses
1307
1308
1308
1309
table.insert(buffer, "<")
1309
1310
table.insert(buffer, tagName)
@@ -1314,9 +1315,9 @@ local function nodeToHtml(buffer, node, encodeTextAsEmail)
1314
1315
1315
1316
if not (attrValue == "" and allowNoAttrValue) then
1316
1317
table.insert(buffer, '="')
1317
-
if attrName == "href" and el.tag == "a" and attrValue:find"^[Mm][Aa][Ii][Ll][Tt][Oo]:" then
1318
+
if attrName == "href" and el.tag == "a" and scrambleEmails and attrValue:find"^[Mm][Aa][Ii][Ll][Tt][Oo]:" then
0 commit comments