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

XHTML Insert Attached Image Broken

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • Major
    • None
    • 7.3
    • None
    • ubuntu-x86, Firefox, Tomcat7

    Description

      Page In Questions URL:

      http://10.255.170.101:8080/xwiki/bin/edit/New/WebHome
      

      Using XHTML syntax and inserting an attached image ALWAYS uses relative paths, and is actually an incorret path :

      <p><img src="/xwiki/bin/download/Main/WebHome/Mario.png" alt="Mario.png"/></p>
      

      This breaks when you try to save & view the page with the following error:

      <p><span class="xwikirenderingerror"></span><span class="xwikirenderingerrordescription hidden"><tt class="wikimodel-verbatim">java.lang.NullPointerException
      	at com.xpn.xwiki.doc.DefaultDocumentAccessBridge.getAttachmentURL(DefaultDocumentAccessBridge.java:698)
      	at org.xwiki.rendering.internal.wiki.XWikiWikiModel.getLinkURL(XWikiWikiModel.java:144)
      	at org.xwiki.rendering.internal.wiki.XWikiWikiModel.getImageURL(XWikiWikiModel.java:176)
      	at org.xwiki.rendering.internal.renderer.xhtml.image.AttachmentXHTMLImageTypeRenderer.getImageSrcAttributeValue(AttachmentXHTMLImageTypeRenderer.java:68)
      	at org.xwiki.rendering.internal.renderer.xhtml.image.AbstractXHTMLImageTypeRenderer.onImage(AbstractXHTMLImageTypeRenderer.java:91)
      	at org.xwiki.rendering.internal.renderer.xhtml.image.DefaultXHTMLImageRenderer.onImage(DefaultXHTMLImageRenderer.java:79)
      	at org.xwiki.rendering.internal.renderer.xhtml.XHTMLChainingRenderer.onImage(XHTMLChainingRenderer.java:548)
      	at org.xwiki.rendering.listener.chaining.AbstractChainingListener.onImage(AbstractChainingListener.java:452)
      	at org.xwiki.rendering.listener.chaining.AbstractChainingListener.onImage(AbstractChainingListener.java:452)
      	at org.xwiki.rendering.listener.chaining.EmptyBlockChainingListener.onImage(EmptyBlockChainingListener.java:405)
      	at org.xwiki.rendering.listener.chaining.AbstractChainingListener.onImage(AbstractChainingListener.java:452)
      	at org.xwiki.rendering.listener.chaining.BlockStateChainingListener.onImage(BlockStateChainingListener.java:617)
      	at org.xwiki.rendering.listener.chaining.AbstractChainingListener.onImage(AbstractChainingListener.java:452)
      	at org.xwiki.rendering.internal.parser.wikimodel.DefaultXWikiGeneratorListener.onImage(DefaultXWikiGeneratorListener.java:859)
      	at org.xwiki.rendering.internal.parser.xhtml.wikimodel.XHTMLXWikiGeneratorListener.onImage(XHTMLXWikiGeneratorListener.java:115)
      	at org.xwiki.rendering.wikimodel.impl.InternalWikiScannerContext.onImage(InternalWikiScannerContext.java:994)
      	at org.xwiki.rendering.wikimodel.impl.WikiScannerContext.onImage(WikiScannerContext.java:480)
      	at org.xwiki.rendering.internal.parser.xhtml.wikimodel.XWikiCommentHandler.handleImageCommentStop(XWikiCommentHandler.java:192)
      	at org.xwiki.rendering.internal.parser.xhtml.wikimodel.XWikiCommentHandler.onComment(XWikiCommentHandler.java:97)
      	at org.xwiki.rendering.wikimodel.xhtml.impl.TagStack.onComment(TagStack.java:233)
      	at org.xwiki.rendering.wikimodel.xhtml.impl.XhtmlHandler.comment(XhtmlHandler.java:234)
      	at org.xwiki.rendering.wikimodel.xhtml.filter.DefaultXMLFilter.comment(DefaultXMLFilter.java:87)
      	at org.xwiki.rendering.wikimodel.xhtml.filter.XHTMLWhitespaceXMLFilter.comment(XHTMLWhitespaceXMLFilter.java:276)
      	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 org.xml.sax.helpers.XMLFilterImpl.parse(XMLFilterImpl.java:357)
      	at org.xwiki.rendering.wikimodel.xhtml.filter.DefaultXMLFilter.parse(DefaultXMLFilter.java:58)
      	at org.xml.sax.helpers.XMLFilterImpl.parse(XMLFilterImpl.java:357)
      	at org.xwiki.rendering.wikimodel.xhtml.filter.DefaultXMLFilter.parse(DefaultXMLFilter.java:58)
      	at org.xml.sax.helpers.XMLFilterImpl.parse(XMLFilterImpl.java:357)
      	at org.xwiki.rendering.wikimodel.xhtml.filter.DefaultXMLFilter.parse(DefaultXMLFilter.java:58)
      	at org.xwiki.rendering.wikimodel.xhtml.XhtmlParser.parse(XhtmlParser.java:132)
      	at org.xwiki.rendering.internal.parser.wikimodel.AbstractWikiModelParser.parse(AbstractWikiModelParser.java:130)
      	at org.xwiki.rendering.internal.parser.wikimodel.AbstractWikiModelParser.parse(AbstractWikiModelParser.java:108)
      	at org.xwiki.wysiwyg.server.internal.converter.DefaultHTMLConverter.fromHTML(DefaultHTMLConverter.java:139)
      	at org.xwiki.wysiwyg.server.filter.ConversionFilter.doFilter(ConversionFilter.java:112)
      	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
      	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
      	at org.xwiki.container.servlet.filters.internal.SetHTTPHeaderFilter.doFilter(SetHTTPHeaderFilter.java:63)
      	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
      	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
      	at com.xpn.xwiki.plugin.webdav.XWikiDavFilter.doFilter(XWikiDavFilter.java:66)
      	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
      	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
      	at org.xwiki.container.servlet.filters.internal.SavedRequestRestorerFilter.doFilter(SavedRequestRestorerFilter.java:208)
      	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
      	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
      	at org.xwiki.container.servlet.filters.internal.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:111)
      	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
      	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
      	at org.xwiki.resource.servlet.RoutingFilter.doFilter(RoutingFilter.java:137)
      	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
      	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
      	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
      	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
      	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)
      	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
      	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
      	at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
      	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
      	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
      	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1041)
      	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607)
      	at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:315)
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      	at java.lang.Thread.run(Thread.java:745)
      </tt></span></p>
      

      I tried fixing it manually by changing it to:

      <p><img src="/xwiki/bin/download/New/WebHome/Mario.png" alt="Mario.png"/></p>
      

      Then it just shows "Mario.png" on the rendered page.

      I have to manually change it to the full (correct) path for it to work properly:

      <p><img src="http://10.255.170.101:8080/xwiki/bin/download/New/WebHome/Mario.png" alt="Mario.png"/></p>
      

      What's funnier still is when I insert the image with XWiki/2.1:

      [[image:Mario.png]]
      

      When I then let it convert that to XHTML by changing syntax, it's even worse than the original:

      <p class="img-wrap"><img src="/xwiki/bin/download/Panels/DocumentInformation/Mario.png" alt="Mario.png"/></p>
      

      So I'm not sure where the bug lies, I tried tracking it down but don't have the time or energy at the moment. I even tried to use a Groovy Event Listener to parse the full path in, but it errors out and sets the page's content to the error output prior to me being able to parse the original img tag in script.

      So I would either suggest giving admins the ability to set an option to use full paths instead of relative ones, or allow to customize a prepended value to the paths

      As for now, is there anywhere I can do this manually without re-compiling xwiki in any way (I don't mind toying with VM or JS), or maybe even manually parsing the page's content prior to (and hopefully avoid) it's null pointer error? As stated before my Groovy Event Listener just isn't getting in there quick enough.

      Attachments

        Activity

          People

            Unassigned Unassigned
            ECCsimmons Gary Simmons
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated: