From 0d97c8ba8dfa4663e86c5827555f980fd47c27a9 Mon Sep 17 00:00:00 2001 From: joehni Date: Tue, 5 Jan 2021 00:38:32 +0100 Subject: [PATCH] Fix endless loop caused by aborted subsequent PI or comment (#124) This closes #124 --- .../plexus/util/xml/pull/MXParser.java | 2 +- .../plexus/util/xml/pull/MXParserTest.java | 52 +++++++++++++++++++ 2 files changed, 53 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/codehaus/plexus/util/xml/pull/MXParser.java b/src/main/java/org/codehaus/plexus/util/xml/pull/MXParser.java index 30c30fef..d44c9a7f 100644 --- a/src/main/java/org/codehaus/plexus/util/xml/pull/MXParser.java +++ b/src/main/java/org/codehaus/plexus/util/xml/pull/MXParser.java @@ -3964,7 +3964,7 @@ private char more() fillBuf(); // this return value should be ignored as it is used in epilog parsing ... if ( reachedEnd ) - return (char) -1; + throw new EOFException( "no more data available" + getPositionDescription() ); } final char ch = buf[pos++]; // line/columnNumber diff --git a/src/test/java/org/codehaus/plexus/util/xml/pull/MXParserTest.java b/src/test/java/org/codehaus/plexus/util/xml/pull/MXParserTest.java index 8e8dc231..e5e04708 100644 --- a/src/test/java/org/codehaus/plexus/util/xml/pull/MXParserTest.java +++ b/src/test/java/org/codehaus/plexus/util/xml/pull/MXParserTest.java @@ -726,6 +726,58 @@ public void testSubsequentMalformedProcessingInstructionNoClosingQuestionMark() * * @throws java.lang.Exception if any. */ + @Test + public void testSubsequentAbortedProcessingInstruction() + throws Exception + { + MXParser parser = new MXParser(); + StringBuilder sb = new StringBuilder(); + sb.append( "" ); + sb.append( "" ); + sb.append( "