From 3103e1f368f59f9eb354fce0c77337d33046a437 Mon Sep 17 00:00:00 2001 From: David Ortner Date: Fri, 18 Aug 2023 11:14:28 +0200 Subject: [PATCH] #999@patch: Adds support for URLs in attributes that doesn't use apostrophs in XMLParser. --- packages/happy-dom/src/xml-parser/XMLParser.ts | 2 +- packages/happy-dom/test/xml-parser/XMLParser.test.ts | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/happy-dom/src/xml-parser/XMLParser.ts b/packages/happy-dom/src/xml-parser/XMLParser.ts index b3214af32..2d6fe68c2 100755 --- a/packages/happy-dom/src/xml-parser/XMLParser.ts +++ b/packages/happy-dom/src/xml-parser/XMLParser.ts @@ -40,7 +40,7 @@ const MARKUP_REGEXP = * Group 9: Attribute name when the attribute has no value (e.g. "disabled" in "
"). */ const ATTRIBUTE_REGEXP = - /\s*([a-zA-Z0-9-_:.$@?]+) *= *([a-zA-Z0-9-_:.$@?{}]+)|\s*([a-zA-Z0-9-_:.$@?]+) *= *"([^"]*)("{0,1})|\s*([a-zA-Z0-9-_:.$@?]+) *= *'([^']*)('{0,1})|\s*([a-zA-Z0-9-_:.$@?]+)/gm; + /\s*([a-zA-Z0-9-_:.$@?]+) *= *([a-zA-Z0-9-_:.$@?{}/]+)|\s*([a-zA-Z0-9-_:.$@?]+) *= *"([^"]*)("{0,1})|\s*([a-zA-Z0-9-_:.$@?]+) *= *'([^']*)('{0,1})|\s*([a-zA-Z0-9-_:.$@?]+)/gm; enum MarkupReadStateEnum { startOrEndTag = 'startOrEndTag', diff --git a/packages/happy-dom/test/xml-parser/XMLParser.test.ts b/packages/happy-dom/test/xml-parser/XMLParser.test.ts index 99237152c..fa4baf3ef 100644 --- a/packages/happy-dom/test/xml-parser/XMLParser.test.ts +++ b/packages/happy-dom/test/xml-parser/XMLParser.test.ts @@ -669,6 +669,14 @@ describe('XMLParser', () => { ); }); + it('Parses attributes with URL without apostrophs.', () => { + const root = XMLParser.parse(document, `Click me`); + + expect(new XMLSerializer().serializeToString(root)).toBe( + 'Click me' + ); + }); + it('Parses attributes with single apostrophs.', () => { const root = XMLParser.parse(document, `
Test
`);