This issue has been created
There is 1 update.
 
 
XWiki Rendering / cid:jira-generated-image-avatar-fa27b4aa-3e4f-40cf-817f-99c59424dc61 XRENDERING-765 Open

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

 
View issue   ยท   Add comment
 

Issue created

 
cid:jira-generated-image-avatar-d6923732-e8bc-4d83-b80a-a95b82273a21 Nikita Petrenko created this issue on 06/Dec/24 09:31
 
Summary: HTML parsing error on saving attempt page that has empty line at the start of the link
Issue Type: cid:jira-generated-image-avatar-fa27b4aa-3e4f-40cf-817f-99c59424dc61 Bug
Affects Versions: 16.10.0
Assignee: Unassigned
Components: Syntax - xhtml/1.0 & html/4.01
Created: 06/Dec/24 09:31
Environment: XWiki 16.10.0 on Tomcat 9.0.97 with PostgreSQL 16
Priority: cid:jira-generated-image-static-major-903ae51e-6f49-4803-8eb4-a0df155807d7 Major
Reporter: Nikita Petrenko
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.

 
 

1 update

 
cid:jira-generated-image-avatar-d6923732-e8bc-4d83-b80a-a95b82273a21 Changes by Nikita Petrenko on 06/Dec/24 09:33
 
Description: h5 h4 . Prerequisites:

Have clean 16.10.0 XWiki
Being authorised as XWiki Admin user
h5
h4
. Steps to reproduce

* Create a new page or replace existing content in any Test Page on Sandbox space with this source code

{code:none}
[[

{{info}}Type your information message here.{{/info}}>>https://www.xwiki.org/xwiki/bin/view/Main/]]
{code}
* Try to save the page

h3 h4 . Actual result

You should receive the error {color:#FF0000}"Failed to save the page. Reason: Bad Request"{color} on save action for this URL
{code:none}
http://localhost:7635/xwiki/bin/save/Development%20Zone/Test%20Page%20with%20Empty%20Paragraph%20and%20Link%20syntax/
{code}
with stack trace error
{code:java}
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
{code}
h3
h4
. Expected result

The new version of the page has been saved successfully.
h3 h4 . Notes

The content that XTHML parse tries to parse
{code:none}
<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>
{code}
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.