Skip to content

Commit

Permalink
Fixed infinite loop in MXParser and reactivate tests in MXParserTest
Browse files Browse the repository at this point in the history
  • Loading branch information
belingueres authored and michael-o committed Dec 29, 2020
1 parent 7e2e788 commit 60bee8a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/main/java/org/codehaus/plexus/util/xml/pull/MXParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -3044,6 +3044,7 @@ private boolean parsePI()
try
{
boolean seenPITarget = false;
boolean seenInnerTag = false;
boolean seenQ = false;
char ch = more();
if ( isS( ch ) )
Expand Down Expand Up @@ -3077,6 +3078,16 @@ else if ( ch == '>' )
throw new XmlPullParserException( "processing instruction PITarget name not found", this,
null );
}
else if ( !seenInnerTag )
{
// seenPITarget && !seenQ
throw new XmlPullParserException( "processing instruction started on line " + curLine
+ " and column " + curColumn + " was not closed", this, null );
}
}
else if ( ch == '<' )
{
seenInnerTag = true;
}
else
{
Expand Down
10 changes: 10 additions & 0 deletions src/test/java/org/codehaus/plexus/util/xml/pull/MXParserTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,7 @@ public void testLargeText_NoOverflow()
assertEquals( XmlPullParser.END_TAG, parser.nextToken() );
}

@Test
public void testMalformedProcessingInstructionAfterTag()
throws Exception
{
Expand All @@ -438,6 +439,7 @@ public void testMalformedProcessingInstructionAfterTag()
}
}

@Test
public void testMalformedProcessingInstructionBeforeTag()
throws Exception
{
Expand All @@ -463,6 +465,7 @@ public void testMalformedProcessingInstructionBeforeTag()
}
}

@Test
public void testMalformedProcessingInstructionSpaceBeforeName()
throws Exception
{
Expand Down Expand Up @@ -490,6 +493,7 @@ public void testMalformedProcessingInstructionSpaceBeforeName()
}
}

@Test
public void testMalformedProcessingInstructionNoClosingQuestionMark()
throws Exception
{
Expand Down Expand Up @@ -517,6 +521,7 @@ public void testMalformedProcessingInstructionNoClosingQuestionMark()
}
}

@Test
public void testSubsequentMalformedProcessingInstructionNoClosingQuestionMark()
throws Exception
{
Expand Down Expand Up @@ -544,6 +549,7 @@ public void testSubsequentMalformedProcessingInstructionNoClosingQuestionMark()
}
}

@Test
public void testMalformedXMLRootElement()
throws Exception
{
Expand All @@ -564,6 +570,7 @@ public void testMalformedXMLRootElement()
}
}

@Test
public void testMalformedXMLRootElement2()
throws Exception
{
Expand All @@ -584,6 +591,7 @@ public void testMalformedXMLRootElement2()
}
}

@Test
public void testMalformedXMLRootElement3()
throws Exception
{
Expand All @@ -605,6 +613,7 @@ public void testMalformedXMLRootElement3()
}
}

@Test
public void testMalformedXMLRootElement4()
throws Exception
{
Expand All @@ -628,6 +637,7 @@ public void testMalformedXMLRootElement4()
}
}

@Test
public void testMalformedXMLRootElement5()
throws Exception
{
Expand Down

0 comments on commit 60bee8a

Please sign in to comment.