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:
1 parent
a18d1358b0
commit
3c6411c16e
1 file changed
+6
-1
@@ -66,6 +66,10 @@ namespace jet {
|
|||||||
bool finished = false;
|
bool finished = false;
|
||||||
while(!finished) {
|
while(!finished) {
|
||||||
in.skipWhitespace();
|
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(">")) {
|
if(in.ifNext(">")) {
|
||||||
// jet-1.4's real parser knew which built-ins never take
|
// jet-1.4's real parser knew which built-ins never take
|
||||||
// a body (its own "void element" list) - real 1.4
|
// a body (its own "void element" list) - real 1.4
|
||||||
@@ -156,7 +160,8 @@ namespace jet {
|
|||||||
keywords[keywordName] = in.getTokenExclude(dq ? "\"" : "'");
|
keywords[keywordName] = in.getTokenExclude(dq ? "\"" : "'");
|
||||||
else
|
else
|
||||||
throw coreutils::Exception("keyword name must be unique for tag.");
|
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) {
|
} else if(keywordName.getLength() > 0) {
|
||||||
// Unquoted attribute value (e.g. TYPE=NE, SCOPE=LOCAL - real
|
// Unquoted attribute value (e.g. TYPE=NE, SCOPE=LOCAL - real
|
||||||
// 1.4 content throughout). Neither quote style matched, but
|
// 1.4 content throughout). Neither quote style matched, but
|
||||||
|
|||||||
Reference in new issue
Block a user