diff options
author | Georg Brandl <georg@python.org> | 2007-03-13 22:49:43 (GMT) |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2007-03-13 22:49:43 (GMT) |
commit | 4aef7275cb993e18cdddf8ae8615d44f757fd717 (patch) | |
tree | d5b516f862e170ea3a866807f8e1b4e1947d6284 /Modules | |
parent | 7e2b6bb24f58d134239cd2641cb5a6b4dbc3c917 (diff) | |
download | cpython-4aef7275cb993e18cdddf8ae8615d44f757fd717.zip cpython-4aef7275cb993e18cdddf8ae8615d44f757fd717.tar.gz cpython-4aef7275cb993e18cdddf8ae8615d44f757fd717.tar.bz2 |
Patch #1185447: binascii.b2a_qp() now correctly quotes binary characters
with ASCII value less than 32. Also, it correctly quotes dots only if
they occur on a single line, as opposed to the previous behavior of
quoting dots if they are the second character of any line.
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/binascii.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/Modules/binascii.c b/Modules/binascii.c index 4dee451..91309f6 100644 --- a/Modules/binascii.c +++ b/Modules/binascii.c @@ -1160,12 +1160,14 @@ binascii_b2a_qp (PyObject *self, PyObject *args, PyObject *kwargs) if ((data[in] > 126) || (data[in] == '=') || (header && data[in] == '_') || - ((data[in] == '.') && (linelen == 1)) || + ((data[in] == '.') && (linelen == 0) && + (data[in+1] == '\n' || data[in+1] == '\r' || data[in+1] == 0)) || (!istext && ((data[in] == '\r') || (data[in] == '\n'))) || ((data[in] == '\t' || data[in] == ' ') && (in + 1 == datalen)) || ((data[in] < 33) && (data[in] != '\r') && (data[in] != '\n') && - (quotetabs && ((data[in] != '\t') || (data[in] != ' '))))) + (quotetabs || + (!quotetabs && ((data[in] != '\t') && (data[in] != ' ')))))) { if ((linelen + 3) >= MAXLINESIZE) { linelen = 0; @@ -1230,12 +1232,14 @@ binascii_b2a_qp (PyObject *self, PyObject *args, PyObject *kwargs) if ((data[in] > 126) || (data[in] == '=') || (header && data[in] == '_') || - ((data[in] == '.') && (linelen == 1)) || + ((data[in] == '.') && (linelen == 0) && + (data[in+1] == '\n' || data[in+1] == '\r' || data[in+1] == 0)) || (!istext && ((data[in] == '\r') || (data[in] == '\n'))) || ((data[in] == '\t' || data[in] == ' ') && (in + 1 == datalen)) || ((data[in] < 33) && (data[in] != '\r') && (data[in] != '\n') && - (quotetabs && ((data[in] != '\t') || (data[in] != ' '))))) + (quotetabs || + (!quotetabs && ((data[in] != '\t') && (data[in] != ' ')))))) { if ((linelen + 3 )>= MAXLINESIZE) { odata[out++] = '='; |