From 3518bc0522b6bcc815950dc637f2b3167e8212e4 Mon Sep 17 00:00:00 2001 From: Mas0nShi Date: Tue, 14 Jun 2022 18:40:42 +0800 Subject: [PATCH 1/2] #504@patch: Fixes XmlParser error parse with tags. --- packages/happy-dom/src/xml-parser/XMLParser.ts | 2 +- .../happy-dom/test/xml-parser/XMLParser.test.ts | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/packages/happy-dom/src/xml-parser/XMLParser.ts b/packages/happy-dom/src/xml-parser/XMLParser.ts index a0bdf7142..9b0541f47 100755 --- a/packages/happy-dom/src/xml-parser/XMLParser.ts +++ b/packages/happy-dom/src/xml-parser/XMLParser.ts @@ -11,7 +11,7 @@ import INode from '../nodes/node/INode'; import IElement from '../nodes/element/IElement'; import HTMLLinkElement from '../nodes/html-link-element/HTMLLinkElement'; -const MARKUP_REGEXP = /<(\/?)([a-z][-.0-9_a-z]*)\s*([^>]*?)(\/?)>/gi; +const MARKUP_REGEXP = /<(\/?)([a-z][-.0-9_a-z]*)\s*([^<>]*?)(\/?)>/gi; const COMMENT_REGEXP = /|<([!?])([^>]*)>/gi; const DOCUMENT_TYPE_ATTRIBUTE_REGEXP = /"([^"]+)"/gm; const ATTRIBUTE_REGEXP = /([^\s=]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|(\S+)))/gms; diff --git a/packages/happy-dom/test/xml-parser/XMLParser.test.ts b/packages/happy-dom/test/xml-parser/XMLParser.test.ts index 85164e4b8..2ae522c00 100644 --- a/packages/happy-dom/test/xml-parser/XMLParser.test.ts +++ b/packages/happy-dom/test/xml-parser/XMLParser.test.ts @@ -185,6 +185,23 @@ describe('XMLParser', () => { `.replace(/[\s]/gm, '') ); + + const root2 = XMLParser.parse( + window.document, + ` + + Title + + + + + ` + ); + expect((root2.children[0].children[1].children[0]).innerText).toBe( + 'var vars = []; for (var i=0;i { From c5052fb726e03094ddb0154643cf6768dc7454b4 Mon Sep 17 00:00:00 2001 From: Mas0nShi Date: Tue, 14 Jun 2022 18:46:05 +0800 Subject: [PATCH 2/2] #504@patch: Continue fixes XmlParser error parse with tags. --- .../happy-dom/test/xml-parser/XMLParser.test.ts | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/packages/happy-dom/test/xml-parser/XMLParser.test.ts b/packages/happy-dom/test/xml-parser/XMLParser.test.ts index 2ae522c00..e55ff23de 100644 --- a/packages/happy-dom/test/xml-parser/XMLParser.test.ts +++ b/packages/happy-dom/test/xml-parser/XMLParser.test.ts @@ -189,19 +189,17 @@ describe('XMLParser', () => { const root2 = XMLParser.parse( window.document, ` - - Title - - - - - ` + + Title + + + + +` ); expect((root2.children[0].children[1].children[0]).innerText).toBe( 'var vars = []; for (var i=0;i {