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

HTML parsing error on saving attempt page that has empty line at the start of the link

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • Major
    • None
    • 16.10.0
    • None
    • XWiki 16.10.0 on Tomcat 9.0.97 with PostgreSQL 16
    • Unknown

    Description

      Prerequisites:

      Have clean 16.10.0 XWiki
      Being authorised as XWiki Admin user

      Steps to reproduce

      • Create a new page or replace existing content in any Test Page on Sandbox space with this source code
      [[
      
      {{info}}Type your information message here.{{/info}}>>https://www.xwiki.org/xwiki/bin/view/Main/]]
      
      • Try to save the page

      Actual result

      You should receive the error "Failed to save the page. Reason: Bad Request" on save action for this URL

      http://localhost:7635/xwiki/bin/save/Development%20Zone/Test%20Page%20with%20Empty%20Paragraph%20and%20Link%20syntax/
      

      with stack trace error

      2024-12-06 09:49:46,144 [http-nio-7635-exec-10 - http://localhost:7635/xwiki/bin/save/Development%20Zone/Test%20Page%20with%20Empty%20Paragraph%20and%20Link%20syntax/] 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:134)
              at org.xwiki.wysiwyg.internal.converter.DefaultRequestParameterConverter.convert(DefaultRequestParameterConverter.java:117)
              at org.xwiki.wysiwyg.internal.converter.DefaultRequestParameterConverter.convert(DefaultRequestParameterConverter.java:96)
              at org.xwiki.wysiwyg.filter.ConversionFilter.doFilter(ConversionFilter.java:58)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:168)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:144)
              at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:168)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:144)
              at org.xwiki.container.servlet.filters.internal.SetHTTPHeaderFilter.doFilter(SetHTTPHeaderFilter.java:63)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:168)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:144)
              at org.xwiki.resource.servlet.RoutingFilter.doFilter(RoutingFilter.java:132)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:168)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:144)
              at org.xwiki.container.servlet.filters.internal.SavedRequestRestorerFilter.doFilter(SavedRequestRestorerFilter.java:208)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:168)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:144)
              at org.xwiki.container.servlet.filters.internal.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:117)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:168)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:144)
              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:482)
              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:660)
              at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
              at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:346)
              at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:396)
              at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:63)
              at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:937)
              at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1791)
              at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:52)
              at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1190)
              at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
              at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:63)
              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.util.NoSuchElementException
              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.util.NoSuchElementException: null
              at java.base/java.util.LinkedList.removeFirst(LinkedList.java:281)
              at java.base/java.util.LinkedList.pop(LinkedList.java:812)
              at org.xwiki.rendering.wikimodel.xhtml.impl.TagStack.popStackParameter(TagStack.java:362)
              at org.xwiki.rendering.internal.parser.xhtml.wikimodel.XWikiCommentHandler.handleLinkCommentStop(XWikiCommentHandler.java:238)
              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
      

      Expected result

      The new version of the page has been saved successfully.

      Notes

      The content that XTHML parse tries to parse

      <p><!--startwikilink:false|-|url|-|https://www.xwiki.org/xwiki/bin/view/Main/--><span class="wikiexternallink"><a href="https://www.xwiki.org/xwiki/bin/view/Main/"><!--startmacro:info|-||-|Type your information message here.--><!--stopmacro--></a></span><!--stopwikilink--></p><div class="box infomessage"><a href="https://www.xwiki.org/xwiki/bin/view/Main/"><span class="sr-only">Information</span></a><p><a href="https://www.xwiki.org/xwiki/bin/view/Main/"><span data-xwiki-non-generated-content="java.util.List&lt;org.xwiki.rendering.block.Block&gt;" class="xwiki-metadata-container">Type your information message here.</span></a></p></div><!--stopmacro--><!--stopwikilink--><p>&nbsp;</p>
      

      The error only happens in an attempt to save the page in a real-time editor via an in-line editor or WYSIWYG editor. I can save page without errors only in Wiki mode. Also, after a failed action, if I check the source code of the page from the CKEditor toolbar, I may accidentally save the page from the Wiki editor with parsed content.

      Attachments

        Activity

          People

            Unassigned Unassigned
            npetrenko Nikita Petrenko
            Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: