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 @@ -3105,6 +3105,10 @@ else if ( !seenInnerTag )
3105
3105
throw new XmlPullParserException ( "processing instruction started on line " + curLine
3106
3106
+ " and column " + curColumn + " was not closed" , this , null );
3107
3107
}
3108
+ else
3109
+ {
3110
+ seenInnerTag = false ;
3111
+ }
3108
3112
}
3109
3113
else if ( ch == '<' )
3110
3114
{
Original file line number Diff line number Diff line change @@ -430,6 +430,37 @@ public void testProcessingInstructionsContainingXml()
430
430
*
431
431
* @throws java.lang.Exception if any.
432
432
*/
433
+ @ Test
434
+ public void testMalformedProcessingInstructionsContainingXmlNoClosingQuestionMark ()
435
+ throws Exception
436
+ {
437
+ StringBuffer sb = new StringBuffer ();
438
+ sb .append ( "<?xml version=\" 1.0\" encoding=\" UTF-8\" ?>\n " );
439
+ sb .append ( "<project />\n " );
440
+ sb .append ( "<?pi\n " );
441
+ sb .append ( " <tag>\n " );
442
+ sb .append ( " </tag>>\n " );
443
+
444
+ MXParser parser = new MXParser ();
445
+ parser .setInput ( new StringReader ( sb .toString () ) );
446
+
447
+ try
448
+ {
449
+ assertEquals ( XmlPullParser .PROCESSING_INSTRUCTION , parser .nextToken () );
450
+ assertEquals ( XmlPullParser .IGNORABLE_WHITESPACE , parser .nextToken () );
451
+ assertEquals ( XmlPullParser .START_TAG , parser .nextToken () );
452
+ assertEquals ( XmlPullParser .END_TAG , parser .nextToken () );
453
+ assertEquals ( XmlPullParser .IGNORABLE_WHITESPACE , parser .nextToken () );
454
+ assertEquals ( XmlPullParser .PROCESSING_INSTRUCTION , parser .nextToken () );
455
+
456
+ fail ( "Should fail since it has invalid PI" );
457
+ }
458
+ catch ( XmlPullParserException ex )
459
+ {
460
+ assertTrue ( ex .getMessage ().contains ( "processing instruction started on line 3 and column 1 was not closed" ) );
461
+ }
462
+ }
463
+
433
464
@ Test
434
465
public void testSubsequentProcessingInstructionShort ()
435
466
throws Exception
You can’t perform that action at this time.
0 commit comments