Modify

Opened 14 years ago

Closed 14 years ago

#6979 closed defect (fixed)

[Patch] Error with unicode milestone title

Reported by: FranRuiz Owned by: Ryan J Ollos
Priority: high Component: WikiCalendarMacro
Severity: major Keywords:
Cc: FranRuiz Trac Release: 0.11

Description

If day milestone name contains any non-ascii character, the macro fails on writing it to the buffer with:

Traceback (most recent call last):                                                                                                     
  File "/usr/lib/python2.6/dist-packages/trac/wiki/formatter.py", line 480, in _macro_formatter                                        
    return macro.process(args, in_paragraph=True)                                                                                      
  File "/usr/lib/python2.6/dist-packages/trac/wiki/formatter.py", line 180, in process                                                 
    text = self.processor(text)                                                                                                        
  File "/usr/lib/python2.6/dist-packages/trac/wiki/formatter.py", line 167, in _macro_processor                                        
    text)                                                                                                                              
  File "/var/trac/test-erp/plugins/WikiCalendarMacro.py", line 283, in expand_macro                                                    
    'day': day                                                                                                                         
UnicodeEncodeError: ('ascii', u'\n<td><a class="day milestone" href="/test/wiki/Meeting/2010/01/21?action=edit" title="Milestone: Primera iteraci\xf3n - Create page Meeting/2010/01/21">21</a></td>', 120, 121, 'ordinal not in range(128)')

Attachments (1)

patch.diff (104 bytes) - added by FranRuiz 14 years ago.
Patch that encodes milestone title in utf-8

Download all attachments as: .zip

Change History (12)

Changed 14 years ago by FranRuiz

Attachment: patch.diff added

Patch that encodes milestone title in utf-8

comment:1 Changed 14 years ago by Ryan J Ollos

Resolution: fixed
Status: newclosed

(In [7891]) Handle milestone names with non-ascii characters. Thank you fjruiz. Fixes #6979.

comment:2 Changed 14 years ago by Ryan J Ollos

I went ahead and applied the patch. I haven't had time to test after applying the patch. Would you be willing to test the latest version of the trunk?

comment:3 Changed 14 years ago by Ryan J Ollos

Also, please go ahead and list your name in the list of Contributors on the wiki page, if you like.

comment:4 in reply to:  2 ; Changed 14 years ago by anonymous

Replying to rjollos:

I went ahead and applied the patch. I haven't had time to test after applying the patch. Would you be willing to test the latest version of the trunk?

It worked for me but I'll test the trunk version as soon as I can.

comment:5 Changed 14 years ago by neil@…

Resolution: fixed
Status: closedreopened

r7891 looks wrong to me - surely it should be title.encode('utf-8') ?

With the current version, I'm seeing "'str' object has no attribute 'unicode'" errors.

comment:6 Changed 14 years ago by Ryan J Ollos

Assuming that the patch author generated the patch from a working version and it was working for him, I'd have to guess that this is dependent on the version of Python you're using. Just a guess though ...

comment:7 in reply to:  5 Changed 14 years ago by anonymous

Replying to neil@dip.sun.ac.za:

r7891 looks wrong to me - surely it should be title.encode('utf-8') ?

I think that according to trac:TracUnicode it's a good idea to use UTF-8 encoding.

With the current version, I'm seeing "'str' object has no attribute 'unicode'" errors.

It would be useful to know which version of Python and system locale are you using.

comment:8 in reply to:  4 Changed 14 years ago by anonymous

Replying to anonymous:

Replying to rjollos:

I went ahead and applied the patch. I haven't had time to test after applying the patch. Would you be willing to test the latest version of the trunk?

It worked for me but I'll test the trunk version as soon as I can.

Yes, the trunk version works for me!

comment:9 in reply to:  6 Changed 14 years ago by neil@…

Replying to rjollos:

Assuming that the patch author generated the patch from a working version and it was working for him, I'd have to guess that this is dependent on the version of Python you're using.

The patch attached to this ticket uses title.encode, so I'm not sure were the unicode method used in r7891 came from.

I'm not aware of any version of python which has a unicode method on string objects.

For reference, this fails with both python 2.5 and 2.6 here (trac 0.11.5 in both cases).

comment:10 Changed 14 years ago by Ryan J Ollos

Stupid mistake on my part ... caused by drinking and patching. I'll fix it in a moment. Thanks for catching this.

comment:11 Changed 14 years ago by Ryan J Ollos

Resolution: fixed
Status: reopenedclosed

(In [7965]) Fix defect that I (stupidly) introduced in [7891]. Fixes #6979.

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.