Modify

Opened 9 years ago

Closed 9 years ago

#12422 closed defect (fixed)

Source inclusion of restructured text fails with encoding error

Reported by: anonymous Owned by: Ryan J Ollos
Priority: normal Component: IncludeMacro
Severity: normal Keywords:
Cc: Trac Release: 1.0

Description (last modified by Ryan J Ollos)

Consider a restructured text file held in the project repository, correctly MIME typed.

Now include in a wiki page: [[Include(source:Project/branches/development/example.rst)]]

The result is:

Error: Macro Include(source:Project/branches/development/example.rst) failed
  
source returned bytes, but no encoding specified

Attachments (0)

Change History (5)

comment:1 Changed 9 years ago by anonymous

From investigating the error message it looks like this may well be due to a change in the Genshi library. See trac:wiki:TracDev/ApiChanges/1.0#Genshimandatory

Last edited 9 years ago by Ryan J Ollos (previous) (diff)

comment:2 Changed 9 years ago by Ryan J Ollos

Description: modified (diff)

comment:3 Changed 9 years ago by Ryan J Ollos

The following patch seems to fix the issue:

  • trunk/includemacro/macros.py

     
    2020from trac.perm import IPermissionRequestor
    2121from trac.resource import ResourceNotFound
    2222from trac.ticket.model import Ticket
     23from trac.util.text import to_unicode
    2324from trac.versioncontrol.api import NoSuchNode, RepositoryManager
    2425from trac.wiki.api import WikiSystem
    2526from trac.wiki.formatter import system_message
     
    154155
    155156        # Escape if needed
    156157        if not self.config.getbool('wiki', 'render_unsafe_content', False):
     158            out = to_unicode(out)
    157159            try:
    158160                out = HTMLParser(StringIO(out)).parse() | HTMLSanitizer()
    159161            except ParseError:

comment:4 Changed 9 years ago by Ryan J Ollos

Description: modified (diff)
Status: newaccepted
Summary: Source inclusion of restructured text failes with encoding errorSource inclusion of restructured text fails with encoding error

comment:5 Changed 9 years ago by Ryan J Ollos

Resolution: fixed
Status: acceptedclosed

In 14777:

3.0.0dev: Send unicode text to Genshi. Fixes #12422.

Genshi 0.7 accepts unicode by default.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Ryan J Ollos.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


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

 
Note: See TracTickets for help on using tickets.