Error on unterminated tags instead of looping forever

The Tag constructor's attribute loop made no progress at end of data, so
a tag that never closed - such as <set value="a\"> with its closing quote
escaped - hung jet-2.0. Throw "unterminated <name> tag." at end of data,
and "unterminated value for X in <name>." when an attribute value's
closing quote is missing.

Needs CoreUtils with the getTokenExclude fix for <set value="a\\">.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
brad ArantandClaude Opus 5.5 committed 2026-11-20 19:57:51 -08:00
1 parent a18d1358b0
commit 3c6411c16e
1 file changed
+6 -1
+6 -1
View File
@@ -66,6 +66,10 @@ namespace jet {
bool finished = false;
while(!finished) {
in.skipWhitespace();
// Nothing below makes progress at end of data, so a tag that
// never closes would otherwise loop here forever.
if(in.eod())
throw coreutils::Exception("unterminated <" + name.str() + "> tag.");
if(in.ifNext(">")) {
// jet-1.4's real parser knew which built-ins never take
// a body (its own "void element" list) - real 1.4
@@ -156,7 +160,8 @@ namespace jet {
keywords[keywordName] = in.getTokenExclude(dq ? "\"" : "'");
else
throw coreutils::Exception("keyword name must be unique for tag.");
in.ifNext(dq ? "\"" : "'");
if(!in.ifNext(dq ? "\"" : "'"))
throw coreutils::Exception("unterminated value for " + keywordName.str() + " in <" + name.str() + ">.");
} else if(keywordName.getLength() > 0) {
// Unquoted attribute value (e.g. TYPE=NE, SCOPE=LOCAL - real
// 1.4 content throughout). Neither quote style matched, but