Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fix parsing of processing instructions containing '>' (issue #65) #66

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions src/main/java/org/codehaus/plexus/util/xml/pull/MXParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -3051,12 +3051,6 @@ else if ( ch == '>' )
throw new XmlPullParserException( "processing instruction PITarget name not found", this,
null );
}
else
{
// seenPITarget && !seenQ
throw new XmlPullParserException( "processing instruction started on line " + curLine
+ " and column " + curColumn + " was not closed", this, null );
}
}
else
{
Expand Down
25 changes: 25 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 @@ -301,6 +301,31 @@ public void testProcessingInstruction()
assertEquals( XmlPullParser.END_TAG, parser.nextToken() );
}

@Test
public void testProcessingInstructionsContainingXml()
throws Exception
{
StringBuffer sb = new StringBuffer();

sb.append( "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" );
sb.append( "<project>\n" );
sb.append( " <?pi\n" );
sb.append( " <tag>\n" );
sb.append( " </tag>\n" );
sb.append( " ?>\n" );
sb.append( "</project>" );

MXParser parser = new MXParser();
parser.setInput( new StringReader( sb.toString() ) );

assertEquals( XmlPullParser.PROCESSING_INSTRUCTION, parser.nextToken() );
assertEquals( XmlPullParser.START_TAG, parser.nextToken() );
assertEquals( XmlPullParser.TEXT, parser.nextToken() ); // whitespace
assertEquals( XmlPullParser.PROCESSING_INSTRUCTION, parser.nextToken() );
assertEquals( XmlPullParser.TEXT, parser.nextToken() ); // whitespace
assertEquals( XmlPullParser.END_TAG, parser.nextToken() );
}

@Test
public void testSubsequentProcessingInstructionShort()
throws Exception
Expand Down