Commit adea4d48 authored by Stephan Kreutzer's avatar Stephan Kreutzer

json_to_xml_2: Endless loop if text literal isn't followed by a comma to...

json_to_xml_2: Endless loop if text literal isn't followed by a comma to introduce the next key name.
parent fc739bba
/* Copyright (C) 2016-2018 Stephan Kreutzer
/* Copyright (C) 2016-2019 Stephan Kreutzer
*
* This file is part of json_to_xml_2, a submodule of the
* digital_publishing_workflow_tools package.
......@@ -326,6 +326,8 @@ public class ParserJson
return 0;
}
boolean whitespaceEntered = false;
do
{
if ((node.getToken().equals("}") == true ||
......@@ -350,6 +352,11 @@ public class ParserJson
}
else if (node.getToken().equals("\\") == true)
{
if (whitespaceEntered == true)
{
throw constructTermination("messageParserMoreTextAfterWhitespaceInTextLiteral", null, null);
}
String string = HandleEscapeSequence();
// Escaping to make sure that there's no \\u encoded XML special
// character in there. Ampersand needs to be the first, otherwise
......@@ -362,10 +369,25 @@ public class ParserJson
}
else if (node.getToken().equals(":") == true)
{
if (whitespaceEntered == true)
{
throw constructTermination("messageParserMoreTextAfterWhitespaceInTextLiteral", null, null);
}
this.writer.write(node.getToken());
}
else if (node.isWhitespace() == true)
{
whitespaceEntered = true;
++this.nodeCursor;
}
else
{
if (whitespaceEntered == true)
{
throw constructTermination("messageParserMoreTextAfterWhitespaceInTextLiteral", null, null);
}
String string = node.getToken();
// Ampersand needs to be the first, otherwise it would double-encode
// other entities.
......
# Copyright (C) 2018 Stephan Kreutzer
# Copyright (C) 2018-2019 Stephan Kreutzer
#
# This file is part of json_to_xml_2, a submodule of the
# digital_publishing_workflow_tools package.
......@@ -22,5 +22,6 @@ messageParserUnsupportedEscapeSequence = Parser: Escape sequence "{0}" not suppo
messageParserEscapeSequenceIncomplete = Parser: Escape sequence "{0}" incomplete.
messageParserEscapeSequenceAtStart = Parser: Escape sequence "{0}" found at start.
messageParserDoubleQuoteInTextLiteral = Parser: Double quotes in text literal.
messageParserMoreTextAfterWhitespaceInTextLiteral = Parser: More text after whitespace following a text literal.
messageParsingError = Parsing error: "{0}" expected, found "{1}".
messageParserNoMoreTokens = Parser: Run out of tokens while more tokens were expected.
# Copyright (C) 2018 Stephan Kreutzer
# Copyright (C) 2018-2019 Stephan Kreutzer
#
# This file is part of json_to_xml_2, a submodule of the
# digital_publishing_workflow_tools package.
......@@ -22,5 +22,6 @@ messageParserUnsupportedEscapeSequence = Parser: Escape-Sequenz "{0}" wird nicht
messageParserEscapeSequenceIncomplete = Parser: Escape-Sequenz "{0}" unvollständig.
messageParserEscapeSequenceAtStart = Parser: Escape-Sequenz "{0}" am Start vorgefunden.
messageParserDoubleQuoteInTextLiteral = Parser: Anführungszeichen in Textliteral.
messageParserMoreTextAfterWhitespaceInTextLiteral = Parser: Weiterer Text nach Leerraum-Zeichen, der einem Textliteral folgte.
messageParsingError = Parsing-Fehler: "{0}" erwartet, "{1}" vorgefunden.
messageParserNoMoreTokens = Parser: Keine weiteren Tokens vorgefunden, obwohl weitere erwartet werden.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment