Uploaded image for project: 'XWiki Platform'
  1. XWiki Platform
  2. XWIKI-3895

Exception while parsing start macro comment with a parameter containing the separator and without content

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Major
    • 1.9 RC1, 2.0 M1
    • 1.9 M2, 1.8.4
    • {Unused} Rendering 2.0
    • None
    • any
    • macro no content exception comment separator
    • Unit
    • Unknown

    Description

      XHTML 1.0 input:

      <!--startmacro:code|-|title="1|-|2"--><!--stopmacro-->
      

      Exception:

      Caused by: org.xwiki.rendering.parser.ParseException: Failed to parse input source
      	at org.xwiki.rendering.internal.parser.wikimodel.AbstractWikiModelParser.parse(AbstractWikiModelParser.java:87)
      	at org.xwiki.rendering.internal.parser.WikiModelXHTMLParser.parse(WikiModelXHTMLParser.java:117)
      	at com.xpn.xwiki.wysiwyg.server.converter.internal.DefaultHTMLConverter.fromHTML(DefaultHTMLConverter.java:66)
      	... 26 more
      Caused by: org.wikimodel.wem.WikiParserException: java.lang.StringIndexOutOfBoundsException: String index out of range: -3
      	at org.wikimodel.wem.xhtml.XhtmlParser.parse(XhtmlParser.java:100)
      	at org.xwiki.rendering.internal.parser.wikimodel.AbstractWikiModelParser.parse(AbstractWikiModelParser.java:85)
      	... 28 more
      Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: -3
      	at java.lang.String.substring(String.java:1949)
      	at java.lang.String.substring(String.java:1916)
      	at org.wikimodel.wem.xhtml.handler.CommentHandler.onComment(CommentHandler.java:66)
      	at org.xwiki.rendering.internal.parser.wikimodel.xhtml.XWikiCommentHandler.onComment(XWikiCommentHandler.java:99)
      	at org.wikimodel.wem.xhtml.impl.XhtmlHandler$TagStack.onComment(XhtmlHandler.java:340)
      	at org.wikimodel.wem.xhtml.impl.XhtmlHandler.comment(XhtmlHandler.java:547)
      	at org.wikimodel.wem.xhtml.filter.DefaultXMLFilter.comment(DefaultXMLFilter.java:75)
      	at org.wikimodel.wem.xhtml.filter.XHTMLWhitespaceXMLFilter.comment(XHTMLWhitespaceXMLFilter.java:217)
      	at org.wikimodel.wem.xhtml.filter.DefaultXMLFilter.comment(DefaultXMLFilter.java:75)
      	at org.wikimodel.wem.xhtml.filter.AccumulationXMLFilter.comment(AccumulationXMLFilter.java:76)
      	at org.wikimodel.wem.xhtml.filter.DefaultXMLFilter.comment(DefaultXMLFilter.java:75)
      	at org.wikimodel.wem.xhtml.filter.DTDXMLFilter.comment(DTDXMLFilter.java:78)
      	at org.apache.xerces.parsers.AbstractSAXParser.comment(Unknown Source)
      	at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanComment(Unknown Source)
      	at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
      	at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
      	at org.apache.xerces.parsers.XML11NonValidatingConfiguration.parse(Unknown Source)
      	at org.apache.xerces.parsers.XML11NonValidatingConfiguration.parse(Unknown Source)
      	at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
      	at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
      	at org.xml.sax.helpers.XMLFilterImpl.parse(XMLFilterImpl.java:357)
      	at org.wikimodel.wem.xhtml.filter.DefaultXMLFilter.parse(DefaultXMLFilter.java:48)
      	at org.xml.sax.helpers.XMLFilterImpl.parse(XMLFilterImpl.java:357)
      	at org.wikimodel.wem.xhtml.filter.DefaultXMLFilter.parse(DefaultXMLFilter.java:48)
      	at org.xml.sax.helpers.XMLFilterImpl.parse(XMLFilterImpl.java:357)
      	at org.wikimodel.wem.xhtml.filter.DefaultXMLFilter.parse(DefaultXMLFilter.java:48)
      	at org.wikimodel.wem.xhtml.XhtmlParser.parse(XhtmlParser.java:97)
      	... 29 more
      

      The expected result is:

      {{code title="1|-|2"/}}
      

      Note that if the content is empty:

      <!--startmacro:code|-|title="1|-|2"|-|--><!--stopmacro-->
      

      the macro comments are parsed correctly into:

      {{code title="1|-|2"}}{{/code}}
      

      Attachments

        Activity

          People

            tmortagne Thomas Mortagne
            mflorea Marius Dumitru Florea
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: