Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#118 - Fixed infinite loop in MXParser and reactivate tests in MXParserTest #119

Merged
merged 1 commit into from Dec 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/main/java/org/codehaus/plexus/util/xml/pull/MXParser.java
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
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