Skip to content

Commit 59cf121

Browse files
toddlipconmichael-o
authored andcommitted
XML processing instructions with embedded '>' fail to parse (#65)
This closes #66 and fixes #65
1 parent b53c04c commit 59cf121

File tree

2 files changed

+25
-6
lines changed

2 files changed

+25
-6
lines changed

src/main/java/org/codehaus/plexus/util/xml/pull/MXParser.java

-6
Original file line numberDiff line numberDiff line change
@@ -3051,12 +3051,6 @@ else if ( ch == '>' )
30513051
throw new XmlPullParserException( "processing instruction PITarget name not found", this,
30523052
null );
30533053
}
3054-
else
3055-
{
3056-
// seenPITarget && !seenQ
3057-
throw new XmlPullParserException( "processing instruction started on line " + curLine
3058-
+ " and column " + curColumn + " was not closed", this, null );
3059-
}
30603054
}
30613055
else
30623056
{

src/test/java/org/codehaus/plexus/util/xml/pull/MXParserTest.java

+25
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,31 @@ public void testProcessingInstruction()
301301
assertEquals( XmlPullParser.END_TAG, parser.nextToken() );
302302
}
303303

304+
@Test
305+
public void testProcessingInstructionsContainingXml()
306+
throws Exception
307+
{
308+
StringBuffer sb = new StringBuffer();
309+
310+
sb.append( "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" );
311+
sb.append( "<project>\n" );
312+
sb.append( " <?pi\n" );
313+
sb.append( " <tag>\n" );
314+
sb.append( " </tag>\n" );
315+
sb.append( " ?>\n" );
316+
sb.append( "</project>" );
317+
318+
MXParser parser = new MXParser();
319+
parser.setInput( new StringReader( sb.toString() ) );
320+
321+
assertEquals( XmlPullParser.PROCESSING_INSTRUCTION, parser.nextToken() );
322+
assertEquals( XmlPullParser.START_TAG, parser.nextToken() );
323+
assertEquals( XmlPullParser.TEXT, parser.nextToken() ); // whitespace
324+
assertEquals( XmlPullParser.PROCESSING_INSTRUCTION, parser.nextToken() );
325+
assertEquals( XmlPullParser.TEXT, parser.nextToken() ); // whitespace
326+
assertEquals( XmlPullParser.END_TAG, parser.nextToken() );
327+
}
328+
304329
@Test
305330
public void testSubsequentProcessingInstructionShort()
306331
throws Exception

0 commit comments

Comments
 (0)