Modify

Opened 16 years ago

Closed 15 years ago

Last modified 15 years ago

#3073 closed defect (fixed)

UnicodeDecodeError re.sub(r'URL="(.*?)"', self.expand_wiki_links, content)

Reported by: Zoran Regvart Owned by: Christian Boos
Priority: normal Component: GraphvizPlugin
Severity: normal Keywords: UnicodeDecodeError URL
Cc: Trac Release: 0.11

Description

Hi, I upgraded to latest for Trac 0.10 and found that URL links no longer support international characters. The changeset, as I see it, that caused this is [3382].

The exception:

Traceback (most recent call last):
  File "/usr/local/lib/python2.5/site-packages/trac/web/main.py", line 406, in dispatch_request
    dispatcher.dispatch(req)
  File "/usr/local/lib/python2.5/site-packages/trac/web/main.py", line 237, in dispatch
    resp = chosen_handler.process_request(req)
  File "/usr/local/lib/python2.5/site-packages/trac/wiki/web_ui.py", line 111, in process_request
    self._render_editor(req, db, page, preview=True)
  File "/usr/local/lib/python2.5/site-packages/trac/wiki/web_ui.py", line 385, in _render_editor
    info['page_html'] = wiki_to_html(page.text, self.env, req, db)
  File "/usr/local/lib/python2.5/site-packages/trac/wiki/formatter.py", line 1001, in wiki_to_html
    Formatter(env, req, absurls, db).format(wikitext, out, escape_newlines)
  File "/usr/local/lib/python2.5/site-packages/trac/wiki/formatter.py", line 795, in format
    self.handle_code_block(line)
  File "/usr/local/lib/python2.5/site-packages/trac/wiki/formatter.py", line 735, in handle_code_block
    self.req, self.code_text)))
  File "/usr/local/lib/python2.5/site-packages/trac/wiki/formatter.py", line 114, in process
    text = self.processor(req, text)
  File "/usr/local/lib/python2.5/site-packages/trac/wiki/formatter.py", line 102, in _macro_processor
    return self.macro_provider.render_macro(req, self.name, text)
  File "build/bdist.freebsd-6.3-STABLE-i386/egg/graphviz/graphviz.py", line 206, in render_macro
    content = re.sub(r'URL="(.*?)"', self.expand_wiki_links, content)
  File "/usr/local/lib/python2.5/re.py", line 150, in sub
    return _compile(pattern, 0).sub(repl, string, count)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc5 in position 73: ordinal not in range(128)

FreeBSD, Trac 0.10.4, Apache 2.2, mod_python 3.3.1, python 2.5.2

Attachments (1)

traclinks-unicode-support.patch (4.2 KB) - added by Christian Boos 15 years ago.
More robust unicode support

Download all attachments as: .zip

Change History (5)

comment:1 Changed 16 years ago by franck34

Same here. Probably depending on the server configuration. Here is my patch :

add

        url      = url.encode('utf-8')

just after

        url      = href and href.groups()[0] or html_url

in function

    def expand_wiki_links(self, match):

Changed 15 years ago by Christian Boos

More robust unicode support

comment:2 Changed 15 years ago by Christian Boos

Trac Release: 0.100.11

I just attached a patch for the 0.11 version of the plugin.

comment:3 Changed 15 years ago by Christian Boos

Owner: changed from Peter Kropf to Christian Boos

comment:4 Changed 15 years ago by Christian Boos

Resolution: fixed
Status: newclosed

In [4395], some additional changes concerning expand_wiki_links and better unicode support were applied.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Christian Boos.
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.