Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions src/Xml.mss
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,9 @@ export function GetTail (element) {

function InitXmlGlobals () {
Self._property:EncodedChar = CreateSparseArray();
EncodedChar[34] = '"';
EncodedChar[60] = '<';
EncodedChar[38] = '&';
EncodedChar[39] = ''';

// Create a string of all characters that have to be entity-encoded
Self._property:EscapedCharacters = '';
Expand Down Expand Up @@ -244,7 +244,7 @@ function CreateXmlTag (name, id, attributesList, isTerminal) {

if (id != null)
{
attrstring = 'xml:id=' & Chr(34) & id & Chr(34);
attrstring = 'xml:id=\'' & id & '\'';
}

if (attributesList != null)
Expand All @@ -257,11 +257,11 @@ function CreateXmlTag (name, id, attributesList, isTerminal) {
if (attrstring = '')
{
// Don't add initial space
attrstring = attr.Name & '=' & Chr(34) & attr.Value & Chr(34);
attrstring = attr.Name & '=\'' & attr.Value & '\'';
}
else
{
attrstring = attrstring & spacer & attr.Name & '=' & Chr(34) & attr.Value & Chr(34);
attrstring = attrstring & spacer & attr.Name & '=\'' & attr.Value & '\'';
}
}
}
Expand Down Expand Up @@ -405,10 +405,8 @@ function EncodeEntities (string) {


function GenerateRandomID () {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not Random, so maybe better call it GenerateID.

id = Self._property:MEIID + 1;
Self._property:MEIID = id;
id = 'm-' & id;
return id;
MEIID = MEIID + 1;
return 'm-' & MEIID;
} //$end


Expand Down
3 changes: 2 additions & 1 deletion test/sib-test/TestXml.mss
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,8 @@ function TestGetSetId (assert, plugin) {

function TestEncodeEntities (assert, plugin) {
_AssertEntityEncoding(assert, 'abc&def', 'abc&def');
_AssertEntityEncoding(assert, '<abc' & Chr(34), '&lt;abc&quot;');
_AssertEntityEncoding(assert, '<abc\'', '&lt;abc&apos;');
_AssertEntityEncoding(assert, '<abc' & Chr(34), '&lt;abc' & Chr(34));
_AssertEntityEncoding(assert, 'abc', 'abc');
_AssertEntityEncoding(assert, '', '');
_AssertEntityEncoding(assert, '&&', '&amp;&amp;');
Expand Down