From 5e9ea0bf1558294e70810ece6a723c45952692a5 Mon Sep 17 00:00:00 2001 From: Nicolas Cannasse Date: Mon, 16 Dec 2024 13:17:58 +0100 Subject: [PATCH] bugfix when string ends with escape sequence (#11883) * bugfix when string ends with escape sequence * add test * fix php too * like this? * argh --------- Co-authored-by: Simon Krajewski --- std/haxe/xml/Parser.hx | 4 +++- std/php/_std/haxe/xml/Parser.hx | 8 ++++---- tests/unit/src/unit/issues/Issue11883.hx | 9 +++++++++ 3 files changed, 16 insertions(+), 5 deletions(-) create mode 100644 tests/unit/src/unit/issues/Issue11883.hx diff --git a/std/haxe/xml/Parser.hx b/std/haxe/xml/Parser.hx index c5e5d01c513..54f6f77420b 100644 --- a/std/haxe/xml/Parser.hx +++ b/std/haxe/xml/Parser.hx @@ -395,8 +395,10 @@ class Parser { if (parent.nodeType == Element) { throw new XmlParserException("Unclosed node <" + parent.nodeName + ">", str, p); } - if (p != start || nsubs == 0) { + if( p != start ) buf.addSub(str, start, p - start); + var str = buf.toString(); + if (str.length > 0 || nsubs == 0) { addChild(Xml.createPCData(buf.toString())); } return p; diff --git a/std/php/_std/haxe/xml/Parser.hx b/std/php/_std/haxe/xml/Parser.hx index 216a96ec81f..884e0becd8c 100644 --- a/std/php/_std/haxe/xml/Parser.hx +++ b/std/php/_std/haxe/xml/Parser.hx @@ -175,9 +175,8 @@ class Parser { p += 8; state = S.DOCTYPE; start = p + 1; - } else if (str.fastCodeAt(p + 1) != '-'.code || str.fastCodeAt(p + 2) != '-'.code) - throw new XmlParserException("Expected