diff --git a/lib/sax.js b/lib/sax.js index 994da9885..6b3bf1202 100644 --- a/lib/sax.js +++ b/lib/sax.js @@ -313,7 +313,9 @@ function parseElementStartPart(source, start, el, currentNSMap, entityReplacer, el.closed = true; case S_ATTR_NOQUOT_VALUE: case S_ATTR: + break; case S_ATTR_SPACE: + el.closed = true; break; //case S_EQ: default: diff --git a/test/parse/__snapshots__/parse-element.test.js.snap b/test/parse/__snapshots__/parse-element.test.js.snap index 50e2ddfd4..468f4e137 100644 --- a/test/parse/__snapshots__/parse-element.test.js.snap +++ b/test/parse/__snapshots__/parse-element.test.js.snap @@ -1,5 +1,23 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`XML Node Parse closing tag with unquoted value ending with // 1`] = ` +Object { + "warning": Array [ + "[xmldom warning] attribute \\"lazy/\\" missed quot(\\")! +@#[line:3,col:3]", + ], +} +`; + +exports[`XML Node Parse closing tag with unquoted value including / followed by space / 1`] = ` +Object { + "warning": Array [ + "[xmldom warning] attribute \\"lazy/\\" missed quot(\\")!! +@#[line:3,col:3]", + ], +} +`; + exports[`XML Node Parse namespaced attributes unclosed root tag will be closed 1`] = ` Object { "actual": "", diff --git a/test/parse/parse-element.test.js b/test/parse/parse-element.test.js index 34a47e5ef..679c60b6c 100644 --- a/test/parse/parse-element.test.js +++ b/test/parse/parse-element.test.js @@ -39,6 +39,117 @@ describe('XML Node Parse', () => { expect(actual).toBe(`Harry Potter`); }); + it('closing tag without attribute value', () => { + const actual = new DOMParser() + .parseFromString( + ``, + 'text/xml' + ) + .toString(); + expect(actual).toBe( + `` + ); + }); + it('closing tag with unquoted value following /', () => { + const actual = new DOMParser() + .parseFromString( + ``, + 'text/xml' + ) + .toString(); + expect(actual).toBe( + `` + ); + }); + it('closing tag with unquoted value following space and /', () => { + const actual = new DOMParser() + .parseFromString( + ``, + 'text/xml' + ) + .toString(); + expect(actual).toBe( + `` + ); + }); + it('closing tag with unquoted value including / followed by space /', () => { + const { errors, parser } = getTestParser(); + const actual = parser + .parseFromString( + ``, + 'text/xml' + ) + .toString(); + expect(errors).toMatchSnapshot(); + expect(actual).toBe( + `` + ); + }); + it('closing tag with unquoted value ending with //', () => { + const { errors, parser } = getTestParser(); + + const actual = parser + .parseFromString( + ``, + 'text/xml' + ) + .toString(); + expect(errors).toMatchSnapshot(); + expect(actual).toBe( + `` + ); + }); + describe('simple attributes', () => { describe('nothing special', () => { it.each(['', '', ''])('%s', (input) => {