Modify

Opened 19 months ago

Closed 19 months ago

Last modified 14 months ago

#10340 closed defect (fixed)

Specify character encoding in pages returned by wiki.getPageHTML

Reported by: nashville_parent Owned by: osimons
Priority: normal Component: XmlRpcPlugin
Severity: normal Keywords: encoding, utf8, utf-8
Cc: olemis Trac Release: 1.0

Description

No character encoding is specified in the HTML returned by wiki.getPageHTML / wiki.getPageHTMLVersion.

By default, Trac appears to use UTF-8 encoding throughout (see page template here), however this is not necessarily the encoding which is used by the web-browser viewing the generated file. For example, my copy of Internet Explorer attempts to render it as Western European (Windows) when encoding auto-select is enabled.

To resolve this, it appears that we can simply change wiki.py line 115 (as at r11148) from -

return '<html><body>%s</body></html>' % html

to:

return '<html><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><body>%s</body></html>' % html

Attachments (0)

Change History (3)

comment:1 Changed 19 months ago by osimons

Thanks for reporting. You are correct in that the output is ambiguous without some declaration of encoding.

  1. If we want UTF-8 always, I should really do .encode('utf-8') on the string explicitly.
  1. Your suggestion will do doubt work, but technically the <meta> tag needs to be wrapped in a <head> tag according to W3C specification. Trivial detail though.
  1. The idea of an API is of course that it should be a machine-to-machine interface, so technically the API can just specify and have the client adjust. Browser rendering is less of an issue with an API as it isn't intended for direct consumption. Yet another alternative would just to 1. above, and have the doc say: "Returns page rendered as HTML (UTF-8 encoded)..." or something to that effect.

Would that suffice? Explicit encode + update docs? As long as the client can rely on UTF-8 there should be no ambiguity, right?

comment:2 Changed 19 months ago by nashville_parent

Yep, that sounds sensible to me.

comment:3 Changed 19 months ago by osimons

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

Fixed in [12107].

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.