From 3c6411c16ee339d5f0afdc8e1d4962c859717017 Mon Sep 17 00:00:00 2001 From: brad Arant Date: Fri, 20 Nov 2026 19:57:51 -0800 Subject: [PATCH] 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 with its closing quote escaped - hung jet-2.0. Throw "unterminated tag." at end of data, and "unterminated value for X in ." when an attribute value's closing quote is missing. Needs CoreUtils with the getTokenExclude fix for . Co-Authored-By: Claude Opus 5.5 --- Tag.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Tag.cpp b/Tag.cpp index b0a3b4d..f01cccc 100644 --- a/Tag.cpp +++ b/Tag.cpp @@ -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