Edgewall Software
Modify

Opened 14 years ago

Closed 14 years ago

#10006 closed defect (fixed)

Wrong wrapping field with long and unicode value in notification email

Reported by: Jun Omae Owned by: Jun Omae
Priority: normal Milestone: 0.12.3
Component: notification Version: 0.12.2rc1
Severity: normal Keywords: unicode email
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:

Description

When a property of ticket is long value and contains multibyte characters, the table cells of ticket notification are formatted wrong.

trac.util.text.wrap uses textwrap.TextWrapper class. TextWrapper doesn't support east asian width.

See #4717 and http://www.unicode.org/reports/tr11/.

Attachments (3)

long-prop-values.png (27.0 KB ) - added by Jun Omae 14 years ago.
t10006-unicode-textwrap.diff (21.1 KB ) - added by Jun Omae 14 years ago.
better-wrapping.png (26.4 KB ) - added by Jun Omae 14 years ago.

Download all attachments as: .zip

Change History (10)

by Jun Omae, 14 years ago

Attachment: long-prop-values.png added

comment:1 by Christian Boos, 14 years ago

I see that FUJIWARA Katsunori wrote a MBTextWrapper for Mercurial. We can't take the code as is (as it's GPL), but maybe that would be possible with his permission though? Unless you have already started to write something Jun, perhaps you could get in touch with him?

by Jun Omae, 14 years ago

by Jun Omae, 14 years ago

Attachment: better-wrapping.png added

in reply to:  1 comment:2 by Jun Omae, 14 years ago

Status: newassigned

Replying to cboos:

I see that FUJIWARA Katsunori wrote a MBTextWrapper for Mercurial. We can't take the code as is (as it's GPL), but maybe that would be possible with his permission though? Unless you have already started to write something Jun, perhaps you could get in touch with him?

Thanks for the information! But I already started to work this issue, and just completed the patch now. t10006-unicode-textwrap.diff

comment:3 by Remy Blank, 14 years ago

Looks very nice! One small question: the textwrap module import was guarded with a try: except: in wrap(). Do you know why this was done? Is the textwrap module not available on some platforms?

in reply to:  3 comment:4 by Jun Omae, 14 years ago

Replying to rblank:

Looks very nice! One small question: the textwrap module import was guarded with a try: except: in wrap(). Do you know why this was done? Is the textwrap module not available on some platforms?

I don't know why…. At least the textwrap module is available since Python 2.3. I removed the try: except:.

See http://docs.python.org/release/2.3/lib/module-textwrap.html.

comment:5 by Remy Blank, 14 years ago

Right, it's a leftover from the time when Trac supported Python < 2.3. So all ok from my side!

comment:6 by Christian Boos, 14 years ago

I've tested it a bit, seems to work great! Maybe just add a docstring to wrap(), in particular saying that it supports / expects unicode (it can break for a str, depending on its content).

comment:7 by Jun Omae, 14 years ago

Milestone: next-minor-0.12.x0.12.3
Resolution: fixed
Status: assignedclosed

Thanks for the reviews! Committed in [10539] with docstring and unit tests.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Jun Omae.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Jun Omae to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.