Uploaded image for project: 'XWiki Rendering'
  1. XWiki Rendering
  2. XRENDERING-753

HTML parsing error when copy/pasting a row with mention macro

    XMLWordPrintable

Details

    • Integration
    • Unknown
    • N/A
    • N/A

    Description

      Use the following input and try to use the rendering annotated XHTML parser to parse it:

      <table><tbody><tr><td>&nbsp;</td><td><!--startmacro:mention|-|reference="XWiki.npetrenko"+style="FULL_NAME"+anchor="XWiki-npetrenko-vmfpml"--><!--stopmacro--></td><td>Here+is+some+Text</td></tr><tr><td>&nbsp;</td><td><span+tabindex="-1"+contenteditable="false"><span+data-macro="startmacro:mention|-|reference=&quot;XWiki.npetrenko&quot;+style=&quot;FULL_NAME&quot;+anchor=&quot;XWiki-npetrenko-vmfpml&quot;"+data-widget="xwiki-macro"+data-xwiki-dom-updated="true"+class="macro"><span+class="hidden+macro-placeholder">macro:mention</span><span+data-macro="startmacro:velocity|-||-|#set+($reference+=+$wikimacro.parameters.reference)
      #set+($style+=+$wikimacro.parameters.style)
      #set+($type+=+&quot;$!wikimacro.parameters.type&quot;)
      #set+($content+=+$services.mentions.format($reference.reference,+$style,+$type))
      #set+($anchor+=+$wikimacro.parameters.anchor)
      #set+($isCurrentUser+=+$xcontext.userReference+==+$reference.reference+&amp;&amp;+($type+==+''+||+$type++==+'user'))
      #set+($cssClasses+=+['xwiki-mention',+'user'])
      #if+($isCurrentUser)
      ++#set+($discard+=+$cssClasses.add('self'))
      #end
      #set+($link+=+$xwiki.getURL($reference.reference,+'view'))
      \{\{html}}
      &lt;\a+id=&quot;$escapetool.xml($anchor)&quot;+class=&quot;$stringtool.join($cssClasses,+'+')&quot;+data-reference=&quot;$escapetool.xml($services.model.serialize($reference.reference,+'default'))&quot;+href=&quot;$escapetool.xml($link)&quot;&gt;##
      ++$escapetool.xml($content)##+Do+not+remove+this+comment+as+it+ensures+that+the+spacing+after+mention+is+not+broken.
      &lt;\/a&gt;
      \{\{/html}}"+class="macro"><span+class="hidden+macro-placeholder">macro:velocity</span><span+data-macro="startmacro:html|-||-|&lt;\a+id=&quot;XWiki-npetrenko-vmfpml&quot;+class=&quot;xwiki-mention+user+self&quot;+data-reference=&quot;xwiki:XWiki.npetrenko&quot;+href=&quot;/xwiki/bin/view/XWiki/npetrenko&quot;&gt;@Nikita+Petrenko&lt;\/a&gt;"+class="macro"><span+class="hidden+macro-placeholder">macro:html</span><!--startwikilink:xwiki:XWiki.npetrenko--><span+class="wikilink"><a+id="XWiki-npetrenko-vmfpml"+class="xwiki-mention+user+self"+href="/xwiki/bin/view/XWiki/npetrenko">@Nikita+Petrenko</a></span><!--stopwikilink--></span></span></span></span></td><td>Here+is+some+Text</td></tr><tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr></tbody></table>
      

      You should get a stack trace with:

      2024-08-02 10:28:08,823 [http-nio-7635-exec-8 - http://localhost:7635/xwiki/bin/save/Sandbox/Table%20With%20Mentioning/] ERROR faultRequestParameterConverter - Exception while parsing HTML
      java.lang.RuntimeException: Exception while parsing HTML
              at org.xwiki.wysiwyg.internal.converter.DefaultHTMLConverter.fromHTML(DefaultHTMLConverter.java:150)
              at org.xwiki.wysiwyg.internal.converter.DefaultRequestParameterConverter.convertHTML(DefaultRequestParameterConverter.java:128)
              at org.xwiki.wysiwyg.internal.converter.DefaultRequestParameterConverter.convert(DefaultRequestParameterConverter.java:111)
              at org.xwiki.wysiwyg.internal.converter.DefaultRequestParameterConverter.convert(DefaultRequestParameterConverter.java:90)
              at org.xwiki.wysiwyg.filter.ConversionFilter.doFilter(ConversionFilter.java:58)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:178)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:153)
              at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:178)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:153)
              at org.xwiki.container.servlet.filters.internal.SetHTTPHeaderFilter.doFilter(SetHTTPHeaderFilter.java:63)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:178)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:153)
              at org.xwiki.resource.servlet.RoutingFilter.doFilter(RoutingFilter.java:132)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:178)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:153)
              at org.xwiki.container.servlet.filters.internal.SavedRequestRestorerFilter.doFilter(SavedRequestRestorerFilter.java:208)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:178)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:153)
              at org.xwiki.container.servlet.filters.internal.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:117)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:178)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:153)
              at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:168)
              at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:90)
              at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:481)
              at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:130)
              at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:93)
              at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:670)
              at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
              at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
              at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:390)
              at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:63)
              at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:928)
              at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1794)
              at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:52)
              at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)
              at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
              at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
              at java.base/java.lang.Thread.run(Thread.java:1583)
      Caused by: org.xwiki.rendering.parser.ParseException: Failed to parse input source
              at org.xwiki.rendering.internal.parser.wikimodel.AbstractWikiModelParser.parse(AbstractWikiModelParser.java:147)
              at org.xwiki.rendering.internal.parser.xhtml.XHTMLParser.parse(XHTMLParser.java:219)
              at org.xwiki.rendering.internal.parser.wikimodel.AbstractWikiModelParser.parse(AbstractWikiModelParser.java:121)
              at org.xwiki.rendering.internal.parser.xhtml.XHTMLParser.parse(XHTMLParser.java:210)
              at org.xwiki.wysiwyg.internal.converter.DefaultHTMLConverter.fromHTML(DefaultHTMLConverter.java:145)
              ... 38 common frames omitted
      Caused by: org.xwiki.rendering.wikimodel.WikiParserException: java.lang.ArrayIndexOutOfBoundsException: Index 1 out of bounds for length 1
              at org.xwiki.rendering.wikimodel.xhtml.XhtmlParser.parse(XhtmlParser.java:136)
              at org.xwiki.rendering.internal.parser.wikimodel.AbstractWikiModelParser.parse(AbstractWikiModelParser.java:141)
              ... 42 common frames omitted
      Caused by: java.lang.ArrayIndexOutOfBoundsException: Index 1 out of bounds for length 1
              at org.xwiki.rendering.internal.parser.xhtml.wikimodel.XHTMLMarkerResourceReferenceParser.parse(XHTMLMarkerResourceReferenceParser.java:55)
              at org.xwiki.rendering.internal.parser.xhtml.wikimodel.XWikiCommentHandler.handleLinkCommentStop(XWikiCommentHandler.java:246)
              at org.xwiki.rendering.internal.parser.xhtml.wikimodel.XWikiCommentHandler.onComment(XWikiCommentHandler.java:99)
              at org.xwiki.rendering.wikimodel.xhtml.impl.TagStack.onComment(TagStack.java:289)
              at org.xwiki.rendering.wikimodel.xhtml.impl.XhtmlHandler.comment(XhtmlHandler.java:232)
              at org.xwiki.rendering.wikimodel.xhtml.filter.DefaultXMLFilter.comment(DefaultXMLFilter.java:87)
              at org.xwiki.rendering.wikimodel.xhtml.filter.XHTMLWhitespaceXMLFilter.comment(XHTMLWhitespaceXMLFilter.java:255)
              at org.xwiki.rendering.wikimodel.xhtml.filter.DefaultXMLFilter.comment(DefaultXMLFilter.java:87)
              at org.xwiki.rendering.wikimodel.xhtml.filter.AccumulationXMLFilter.comment(AccumulationXMLFilter.java:94)
              at org.xwiki.rendering.wikimodel.xhtml.filter.DefaultXMLFilter.comment(DefaultXMLFilter.java:87)
              at org.xwiki.rendering.wikimodel.xhtml.filter.DTDXMLFilter.comment(DTDXMLFilter.java:95)
              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 java.xml/org.xml.sax.helpers.XMLFilterImpl.parse(XMLFilterImpl.java:345)
              at org.xwiki.rendering.wikimodel.xhtml.filter.DefaultXMLFilter.parse(DefaultXMLFilter.java:58)
              at java.xml/org.xml.sax.helpers.XMLFilterImpl.parse(XMLFilterImpl.java:345)
              at org.xwiki.rendering.wikimodel.xhtml.filter.DefaultXMLFilter.parse(DefaultXMLFilter.java:58)
              at java.xml/org.xml.sax.helpers.XMLFilterImpl.parse(XMLFilterImpl.java:345)
              at org.xwiki.rendering.wikimodel.xhtml.filter.DefaultXMLFilter.parse(DefaultXMLFilter.java:58)
              at org.xwiki.rendering.wikimodel.xhtml.XhtmlParser.parse(XhtmlParser.java:134)
              ... 43 common frames omitted
      

      See also XRENDERING-754

      Attachments

        Issue Links

          Activity

            People

              surli Simon Urli
              npetrenko Nikita Petrenko
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: