[Python-bugs-list] [Bug #127718] binascii_a2b_uu '@' is 0? trailing garbage bug.

noreply@sourceforge.net noreply@sourceforge.net
Fri, 05 Jan 2001 19:56:47 -0800


Bug #127718, was updated on 2001-Jan-05 19:56
Here is a current snapshot of the bug.

Project: Python
Category: Python Library
Status: Open
Resolution: None
Bug Group: None
Priority: 5
Submitted by: donut
Assigned to : nobody
Summary: binascii_a2b_uu '@' is 0?  trailing garbage bug.

Details: I first came upon the problem that binascii.a2b_uu does not handle
correctly uuencoded files that end with `.  After investigation of the
uuencode standard and the binascii.c module, I believe I have found the
reason:

The binascii module source says that some uuencoders use '@' as zero
instead of space, but (at least in ascii):

>>> ord('@')-32
32

The only thing I can think of is that perhaps this comment was written by
someone using a different charset where ord('@') is 96 rather than 64 as in
ascii.  I believe this is confirmed by the comment and the following code:

/* Check the character for legality
** The 64 in stead of the expected 63 is because
** there are a few uuencodes out there that use
** '@' as zero instead of space.
*/
if ( this_ch < ' ' || this_ch > (' ' + 64)) {

this comment certainly seems to indicate that the author is expecting '
'+64 to be '@'.  But in ascii this is actually '`'.  While this isn't a
problem in this portion of the code since it is calculated numerically,
later on we have:

/* Extra '@' may be written as padding in some cases */
if ( this_ch != ' ' && this_ch != '@' &&
this_ch != '\n' && this_ch != '\r' ) {
PyErr_SetString(Error, "Trailing garbage");


In this case, I believe the '@' should really be '`', or preferably ' '+64,
to avoid any more charset confusion.


Of course, I could have missed something and '@', really is correct..  in
that case '`' should be added since I see many uuencoders using that
instead of space.. but I really believe that this is what the code was
originally trying to do anyway. (especially since it does do this in the
illegal char detection code.)


For detailed info, follow this link:
http://sourceforge.net/bugs/?func=detailbug&bug_id=127718&group_id=5470