Bug 2564 - UTF-8 encoding is destroyed by 'notify' in email subjects
Summary: UTF-8 encoding is destroyed by 'notify' in email subjects
Status: RESOLVED FIXED
Alias: None
Product: Mercurial
Classification: Unclassified
Component: Mercurial (show other bugs)
Version: unspecified
Hardware: All All
: normal bug
Assignee: Bugzilla
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-12-23 01:21 UTC by Oleg Smolsky
Modified: 2012-05-13 05:07 UTC (History)
4 users (show)

See Also:
Python Version: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Oleg Smolsky 2010-12-23 01:21 UTC
The "Notify" extension has a bug around line 218 where it tries to shorten 
the subject by chopping symbols off the end. The code works correctly with 
plain English/ASCII yet breaks legitimate UTF-8 comments:

1) subject = subject[:maxsubject - 3] + '...' 
 - this line can cut in the middle of a multi-byte symbol 
 - the code can only work with ASCII

2) mail.headencode(self.ui, subject, self.charsets, self.test)
 - this call fails to detect encoding
 - and spits out bytes encoded/transcoded in some weird way

3) the final result - rubbish in email subjects
Comment 1 Yuya Nishihara 2010-12-23 10:42 UTC
Posted a patch to mercurial-devel:
http://thread.gmane.org/gmane.comp.version-control.mercurial.devel/37078

Could you try it?
Comment 2 Oleg Smolsky 2010-12-23 10:56 UTC
I certainly can try it. Could you explain how I can patch my existing Debian 
installation please? I am using a binary package from the "experimental" sub-
distro which, I believe, contains compiled .pyc files...
Comment 3 Yuya Nishihara 2010-12-23 11:10 UTC
> I certainly can try it. Could you explain how I can patch my existing 
Debian installation please?

Hmm, clone http://selenic.com/repo/hg#stable and apply patches.
Then, use the patched notify extension in place of debian package's:

[extensions]
notify = /path/to/patched/hg/hgext/notify.py
Comment 4 Yuya Nishihara 2010-12-23 11:15 UTC
> Then, use the patched notify extension in place of debian package's:

Ah, no, this won't work because I modified util.py.
The easiest way is to use source install instead of packaged Mercurial:

$ hg clone http://selenic.com/repo/hg#stable
$ cd hg
# apply patches
# make local
Comment 5 Oleg Smolsky 2010-12-23 11:43 UTC
Hmm... the install from source is not an acceptable option as it will force 
me to manually maintain the Mercurial application from this point on.

I will test your code if you can provide the extension that I can temporary 
install and then roll back at will. Say, could you give me the notify.py file 
with a local copy of the elipsis() function please?
Comment 6 HG Bot 2011-01-01 19:00 UTC
Fixed by http://selenic.com/repo/hg/rev/e3bf16703e26
Yuya Nishihara <yuya@tcha.org>
util: fix ellipsis() not to break multi-byte sequence (issue2564)

(please test the fix)
Comment 7 Bugzilla 2012-05-12 09:15 UTC

--- Bug imported by bugzilla@serpentine.com 2012-05-12 09:15 EDT  ---

This bug was previously known as _bug_ 2564 at http://mercurial.selenic.com/bts/issue2564