Bidmaron
October 17th, 2017, 02:49
MW, you have the following in the onTableRoll handler of the manager_table.lua file:
elseif (bTopTable or (#v.aTableLinks == 0)) then
if sText:match("^<[biu]>") then
sAddDesc = sAddDesc .. "<p>" .. UtilityManager.encodeXML(sText):gsub("<(/?[phbiu])>", "<%1>") .. "</p>";
elseif sText:match("^<[ph]>") then
sAddDesc = sAddDesc .. UtilityManager.encodeXML(sText):gsub("<(/?[phbiu])>", "<%1>");
else
sAddDesc = sAddDesc .. "<list><li>" .. UtilityManager.encodeXML(sText) .. "</li></list>";
end
end
This code is in the section that outputs table rolls to a story window. What it appears to do is:
1. search for bold, underlined, or italicized text, encode that text and then strip out the xml safe tags (the < and >) after the XML encoding.
2. do the same for paragraph and heading tags in text.
3. if the text doesn't have any of the tags, surround it with xml encoded text bounded by table tags (<list><li>)
Later, the text is then saved to the story data node.
So, the questions I have are:
1. Why encode the text with encodeXML and then go to the trouble to reverse the encoding for the text formatting tags?
2. Does the DB.setValue call with a formattedtext type field not do the xml encoding?
3. If the answer to #2 is yes, then why is it necessary to explicitly encode the generated table text in the code above?
4. If the answer to #2 is no, then how does the '<' character which is forbidden in xml (other than tags) ever get encoded since you are stripping the encoding out?
elseif (bTopTable or (#v.aTableLinks == 0)) then
if sText:match("^<[biu]>") then
sAddDesc = sAddDesc .. "<p>" .. UtilityManager.encodeXML(sText):gsub("<(/?[phbiu])>", "<%1>") .. "</p>";
elseif sText:match("^<[ph]>") then
sAddDesc = sAddDesc .. UtilityManager.encodeXML(sText):gsub("<(/?[phbiu])>", "<%1>");
else
sAddDesc = sAddDesc .. "<list><li>" .. UtilityManager.encodeXML(sText) .. "</li></list>";
end
end
This code is in the section that outputs table rolls to a story window. What it appears to do is:
1. search for bold, underlined, or italicized text, encode that text and then strip out the xml safe tags (the < and >) after the XML encoding.
2. do the same for paragraph and heading tags in text.
3. if the text doesn't have any of the tags, surround it with xml encoded text bounded by table tags (<list><li>)
Later, the text is then saved to the story data node.
So, the questions I have are:
1. Why encode the text with encodeXML and then go to the trouble to reverse the encoding for the text formatting tags?
2. Does the DB.setValue call with a formattedtext type field not do the xml encoding?
3. If the answer to #2 is yes, then why is it necessary to explicitly encode the generated table text in the code above?
4. If the answer to #2 is no, then how does the '<' character which is forbidden in xml (other than tags) ever get encoded since you are stripping the encoding out?