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 )
31583158 throw new XmlPullParserException ( "processing instruction started on line " + curLine
31593159 + " and column " + curColumn + " was not closed" , this , null );
31603160 }
3161+ else
3162+ {
3163+ seenInnerTag = false ;
3164+ }
31613165 }
31623166 else if ( ch == '<' )
31633167 {
Original file line number Diff line number Diff line change @@ -432,6 +432,37 @@ public void testProcessingInstructionsContainingXml()
432432 *
433433 * @throws java.lang.Exception if any.
434434 */
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+
435466 @ Test
436467 public void testSubsequentProcessingInstructionShort ()
437468 throws Exception
You can’t perform that action at this time.
0 commit comments