Skip to content

Commit 8a090d7

Browse files
francescobarberaamitguptagwl
authored andcommitted
fix validation for tag on multiple lines (#164)
1 parent 65c39be commit 8a090d7

2 files changed

Lines changed: 22 additions & 1 deletion

File tree

spec/validator_spec.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,4 +399,16 @@ describe("XMLParser", function() {
399399
var result = validator.validate(xmlData).err;
400400
expect(result).toEqual(expected);
401401
});
402+
403+
it('should validate xml with a tag attribute splitted on more lines', () => {
404+
const xmlData = `
405+
<name
406+
attribute1="attribute1"
407+
attribute2="attribute2"
408+
/>
409+
`;
410+
411+
var result = validator.validate(xmlData);
412+
expect(result).toEqual(true);
413+
});
402414
});

src/validator.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,16 @@ exports.validate = function(xmlData, options) {
4848
}
4949
//read tagname
5050
let tagName = '';
51-
for (; i < xmlData.length && xmlData[i] !== '>' && xmlData[i] !== ' ' && xmlData[i] !== '\t'; i++) {
51+
for (
52+
;
53+
i < xmlData.length &&
54+
xmlData[i] !== '>' &&
55+
xmlData[i] !== ' ' &&
56+
xmlData[i] !== '\t' &&
57+
xmlData[i] !== '\n' &&
58+
xmlData[i] !== '\r';
59+
i++
60+
) {
5261
tagName += xmlData[i];
5362
}
5463
tagName = tagName.trim();

0 commit comments

Comments
 (0)