Skip to content

Commit d6bce3b

Browse files
committed
allow long attribute expressions
1 parent 9a2561b commit d6bce3b

1 file changed

Lines changed: 11 additions & 8 deletions

File tree

src/xmlparser/OrderedObjParser.js

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -656,11 +656,13 @@ function isItStopNode() {
656656
*/
657657
function tagExpWithClosingIndex(xmlData, i, closingChar = ">") {
658658
let attrBoundary = 0;
659-
const chars = [];
660659
const len = xmlData.length;
661660
const closeCode0 = closingChar.charCodeAt(0);
662661
const closeCode1 = closingChar.length > 1 ? closingChar.charCodeAt(1) : -1;
663662

663+
let result = '';
664+
let segmentStart = i;
665+
664666
for (let index = i; index < len; index++) {
665667
const code = xmlData.charCodeAt(index);
666668

@@ -671,17 +673,18 @@ function tagExpWithClosingIndex(xmlData, i, closingChar = ">") {
671673
} else if (code === closeCode0) {
672674
if (closeCode1 !== -1) {
673675
if (xmlData.charCodeAt(index + 1) === closeCode1) {
674-
return { data: String.fromCharCode(...chars), index };
676+
result += xmlData.substring(segmentStart, index);
677+
return { data: result, index };
675678
}
676679
} else {
677-
return { data: String.fromCharCode(...chars), index };
680+
result += xmlData.substring(segmentStart, index);
681+
return { data: result, index };
678682
}
679-
} else if (code === 9) { // \t
680-
chars.push(32); // space
681-
continue;
683+
} else if (code === 9 && !attrBoundary) { // \t - only replace with space outside attribute values
684+
// Flush accumulated segment, add space, start new segment
685+
result += xmlData.substring(segmentStart, index) + ' ';
686+
segmentStart = index + 1;
682687
}
683-
684-
chars.push(code);
685688
}
686689
}
687690

0 commit comments

Comments
 (0)