Menu

#5 String.Format exception

open
nobody
None
5
2012-09-20
2012-09-20
Anonymous
No

Found in version 1.0.1 in the 'Files' section.

The following xml will generate an assertion when trying to generate an error:

<nodeName>
</node>

when parsed with the options:

tidy.Options.FixComments = true;
tidy.Options.XmlTags = true;
tidy.Options.XmlOut = true;

The fix for this is to replace:
(Report.cs)
public static void Error(Lexer lexer, Node element, Node node, short code)
{
/* -- CUT -- */
else if (code == UNEXPECTED_ENDTAG)
{
string message;
if (element != null)
{
message = String.Format(GetMessage("unexpected_endtag_suffix"), element.Element);
}
else
{
message = String.Format(GetMessage("unexpected_endtag"), node.Element, element.Element);
}

AddMessage(lexer, message, MessageLevel.Error);
}
}

with:

public static void Error(Lexer lexer, Node element, Node node, short code)
{
/* -- CUT -- */
else if (code == UNEXPECTED_ENDTAG)
{
string message;
if (element != null)
{
message = String.Format(GetMessage("unexpected_endtag_suffix"), node.Element, element.Element);
}
else
{
message = String.Format(GetMessage("unexpected_endtag"), node.Element);
}

AddMessage(lexer, message, MessageLevel.Error);
}
}

Discussion


Log in to post a comment.

MongoDB Logo MongoDB