Modify

Opened 3 years ago

Closed 3 years ago

#8466 closed defect (fixed)

wiki.getPageHTML on page with image returns empty image

Reported by: ruidc@… Owned by: osimons
Priority: high Component: XmlRpcPlugin
Severity: major Keywords: image url wiki_to_html
Cc: Trac Release: 0.12

Description (last modified by rjollos)

Image attached to page as [[Image(tab1.JPG)]] is fine in wiki, but calling getPageHTML returns empty tag: <img />

Trac v0.12.1
TracXMLRPC v1.1.0

Attachments (0)

Change History (5)

comment:1 Changed 3 years ago by ruidc@…

Forgot to mention, getPage returns [[Image(tab1.JPG)]] correctly.

comment:2 Changed 3 years ago by ruidc@…

  • Keywords url wiki_to_html added

The following patch fixes it for me (thx to comment from t:#9292).

NB: that according to the trac source, wiki_to_html has been deprecated and format_to_html should be used instead.

  • wiki.py

    a b  
    1414from trac.resource import Resource, ResourceNotFound 
    1515from trac.wiki.api import WikiSystem 
    1616from trac.wiki.model import WikiPage 
    17 from trac.wiki.formatter import wiki_to_html 
     17from trac.wiki.formatter import wiki_to_html, format_to_html 
     18from trac.mimeview import Context 
    1819 
    1920from tracrpc.api import IXMLRPCHandler, expose_rpc, Binary 
    2021from tracrpc.util import StringIO, to_utimestamp, from_utimestamp 
     
    9495    def getPageHTML(self, req, pagename, version=None): 
    9596        """ Return page in rendered HTML, latest version. """ 
    9697        text = self.getPage(req, pagename, version) 
    97         html = wiki_to_html(text, self.env, req, absurls=1) 
     98        #html = wiki_to_html(text, self.env, req, absurls=1) 
     99        resource = Resource('wiki', pagename) 
     100        context = Context.from_request(req, resource, absurls=1) 
     101        html = format_to_html(self.env, context, text) 
    98102        return '<html><body>%s</body></html>' % html 
    99103 
    100104    def getAllPages(self, req): 

comment:3 Changed 3 years ago by rjollos

  • Description modified (diff)

comment:4 follow-up: Changed 3 years ago by osimons

(In [9818]) XmlRpcPlugin: Fix for rendering wiki HTML in proper context for correct links and references to relative resources (such as image attachment reference).

Added test for absolute and relative attachment, but test only passes on Trac 0.11 - Trac 0.12 seems to have a bug here...

References #8466

comment:5 in reply to: ↑ 4 Changed 3 years ago by osimons

  • Resolution set to fixed
  • Status changed from new to closed

Replying to osimons:

Added test for absolute and relative attachment, but test only passes on Trac 0.11 - Trac 0.12 seems to have a bug here...

I stand corrected. After messing around with my development setup and re-running test switching 0.11 <-> 0.12, it has now decided to work for 0.12 as well (using latest 0.12.2 at least).

I now consider the issue fixed, but please reopen if something is still not right.

Thanks for report and patch!

Add Comment

Modify Ticket

Action
as closed .
as The resolution will be set. Next status will be 'closed'.
to The owner will be changed from osimons. Next status will be 'closed'.
The resolution will be deleted. Next status will be 'reopened'.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.