File tree Expand file tree Collapse file tree 2 files changed +35
-0
lines changed
main/java/org/codehaus/plexus/util/xml/pull
test/java/org/codehaus/plexus/util/xml/pull Expand file tree Collapse file tree 2 files changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -3158,6 +3158,10 @@ else if ( !seenInnerTag )
3158
3158
throw new XmlPullParserException( "processing instruction started on line " + curLine
3159
3159
+ " and column " + curColumn + " was not closed", this, null );
3160
3160
}
3161
+ else
3162
+ {
3163
+ seenInnerTag = false;
3164
+ }
3161
3165
}
3162
3166
else if ( ch == '<' )
3163
3167
{
Original file line number Diff line number Diff line change @@ -432,6 +432,37 @@ public void testProcessingInstructionsContainingXml()
432
432
*
433
433
* @throws java.lang.Exception if any.
434
434
*/
435
+ @Test
436
+ public void testMalformedProcessingInstructionsContainingXmlNoClosingQuestionMark()
437
+ throws Exception
438
+ {
439
+ StringBuffer sb = new StringBuffer();
440
+ sb.append( "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" );
441
+ sb.append( "<project />\n" );
442
+ sb.append( "<?pi\n" );
443
+ sb.append( " <tag>\n" );
444
+ sb.append( " </tag>>\n" );
445
+
446
+ MXParser parser = new MXParser();
447
+ parser.setInput( new StringReader( sb.toString() ) );
448
+
449
+ try
450
+ {
451
+ assertEquals( XmlPullParser.PROCESSING_INSTRUCTION, parser.nextToken() );
452
+ assertEquals( XmlPullParser.IGNORABLE_WHITESPACE, parser.nextToken() );
453
+ assertEquals( XmlPullParser.START_TAG, parser.nextToken() );
454
+ assertEquals( XmlPullParser.END_TAG, parser.nextToken() );
455
+ assertEquals( XmlPullParser.IGNORABLE_WHITESPACE, parser.nextToken() );
456
+ assertEquals( XmlPullParser.PROCESSING_INSTRUCTION, parser.nextToken() );
457
+
458
+ fail( "Should fail since it has invalid PI" );
459
+ }
460
+ catch ( XmlPullParserException ex )
461
+ {
462
+ assertTrue( ex.getMessage().contains( "processing instruction started on line 3 and column 1 was not closed" ) );
463
+ }
464
+ }
465
+
435
466
@Test
436
467
public void testSubsequentProcessingInstructionShort()
437
468
throws Exception
You can’t perform that action at this time.
0 commit comments