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

Empty html macro causes parser to break.

    XMLWordPrintable

    Details

    • Difficulty:
      Unknown
    • Similar issues:

      Description

      As of revision 27190, the parser breaks when a document is saved containing an empty html macro.
      This bug does not exist in 2.2

      This

      {{html}}
      {{/html}}
      

      Causes this:

      Wrapped Exception:
      
      java.lang.NullPointerException
      	at com.xpn.xwiki.doc.XWikiDocument.getXDOM(XWikiDocument.java:6755)
      	at com.xpn.xwiki.doc.XWikiDocument.getUniqueLinkedPages(XWikiDocument.java:3933)
      	at com.xpn.xwiki.doc.XWikiDocument.getUniqueWikiLinkedPages(XWikiDocument.java:3812)
      	at com.xpn.xwiki.store.XWikiHibernateStore.saveLinks(XWikiHibernateStore.java:1913)
      	at com.xpn.xwiki.store.XWikiHibernateStore.saveXWikiDoc(XWikiHibernateStore.java:620)
      	at com.xpn.xwiki.store.XWikiCacheStore.saveXWikiDoc(XWikiCacheStore.java:182)
      	at com.xpn.xwiki.store.XWikiCacheStore.saveXWikiDoc(XWikiCacheStore.java:175)
      	at com.xpn.xwiki.XWiki.saveDocument(XWiki.java:1343)
      

      If the html macro is wrapped in a velocity macro, then the SaveAndContinue button works and the page can be viewed as normal but the SaveAndView button makes the page not render correctly even after a refresh (bad XDOM?)

      This:

      {{velocity}}
      {{html}}
      {{/html}}
      {{/velocity}}
      

      Causes this:

      Caused by: org.xwiki.rendering.parser.ParseException: Failed to parse input source
      	at org.xwiki.rendering.internal.parser.wikimodel.AbstractWikiModelParser.parse(AbstractWikiModelParser.java:136)
      	at org.xwiki.rendering.internal.parser.wikimodel.AbstractWikiModelParser.parse(AbstractWikiModelParser.java:97)
      	at org.xwiki.rendering.macro.script.AbstractScriptMacro.parseSourceSyntax(AbstractScriptMacro.java:381)
      	... 91 more
      Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: -1
      	at java.lang.AbstractStringBuilder.substring(AbstractStringBuilder.java:881)
      	at java.lang.StringBuffer.substring(StringBuffer.java:416)
      	at org.wikimodel.wem.xwiki.xwiki20.javacc.XWikiScanner.normalizeMacroContent(XWikiScanner.java:84)
      	at org.wikimodel.wem.xwiki.xwiki20.javacc.XWikiScanner.macro(XWikiScanner.java:1272)
      	at org.wikimodel.wem.xwiki.xwiki20.javacc.XWikiScanner.macroBlock(XWikiScanner.java:1195)
      	at org.wikimodel.wem.xwiki.xwiki20.javacc.XWikiScanner.docElements(XWikiScanner.java:698)
      	at org.wikimodel.wem.xwiki.xwiki20.javacc.XWikiScanner.doParse(XWikiScanner.java:671)
      	at org.wikimodel.wem.xwiki.xwiki20.javacc.XWikiScanner.parse(XWikiScanner.java:48)
      	at org.wikimodel.wem.xwiki.xwiki20.XWikiParser.parse(XWikiParser.java:43)
      	at org.xwiki.rendering.internal.parser.wikimodel.AbstractWikiModelParser.parse(AbstractWikiModelParser.java:134)
      	... 93 more
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              tmortagne Thomas Mortagne
              Reporter:
              calebjamesdelisle CalebJamesDeLisle
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Date of First Response: