Staging
v0.5.1
swh:1:snp:635f4099902912592851108bcac178ff574f7c5f
Revision 2bfcf5d1f1b0f20e5f2efe5f3dca2ce808f57263 authored by Barry Warsaw on 25 July 2006, 13:06:56 UTC, committed by Barry Warsaw on 25 July 2006, 13:06:56 UTC
decode_rfc2231(): Be more robust against buggy RFC 2231 encodings.
Specifically, instead of raising a ValueError when there is a single
tick in the parameter, simply return that the entire string unquoted, with
None for both the charset and the language.  Also, if there are more than 2
ticks in the parameter, interpret the first three parts as the standard RFC
2231 parts, then the rest of the parts as the encoded string.

More RFC 2231 improvements for the email 4.0 package.  As Mark Sapiro
rightly points out there are really two types of continued headers
defined in this RFC (i.e. "encoded" parameters with the form
"name*0*=" and unencoded parameters with the form "name*0="), but we
were were handling them both the same way and that isn't correct.

This patch should be much more RFC compliant in that only encoded
params are %-decoded and the charset/language information is only
extract if there are any encoded params in the segments.  If there are
no encoded params then the RFC says that there will be no
charset/language parts.

Note however that this will change the return value for
Message.get_param() in some cases.  For example, whereas before if you
had all unencoded param continuations you would have still gotten a
3-tuple back from this method (with charset and language == None), you
will now get just a string. I don't believe this is a backward
incompatible change though because the documentation for this method
already indicates that either return value is possible and that you
must do an isinstance(val, tuple) check to discriminate between the
two.  (Yeah that API kind of sucks but we can't change /that/ without
breaking code.)

Test cases, some documentation updates, and a NEWS item accompany this
patch.

Original fewer-than-3-parts fix by Tokio Kikuchi.

Resolves SF bug # 1218081.

Also, bump the package version number to 2.5.8 for release.
1 parent e3e7851
History
Tip revision: 550e4673be538d98b6ddf5550b3922539cf5c4b2 authored by Victor Stinner on 08 December 2020, 23:32:54 UTC
bpo-32381: Add _PyRun_SimpleFileObject() (GH-23709)
Tip revision: 550e467
File Mode Size
Demo
Doc
Grammar
Include
Lib
Mac
Misc
Modules
Objects
PC
PCbuild
Parser
Python
RISCOS
Tools
.cvsignore -rw-r--r-- 109 bytes
.hgtags -rw-r--r-- 2.6 KB
LICENSE -rw-r--r-- 12.9 KB
Makefile.pre.in -rw-r--r-- 31.3 KB
README -rw-r--r-- 48.3 KB
aclocal.m4 -rw-r--r-- 2.1 KB
configure -rwxr-xr-x 590.0 KB
configure.in -rw-r--r-- 86.0 KB
install-sh -rwxr-xr-x 7.0 KB
pyconfig.h.in -rw-r--r-- 24.7 KB
setup.py -rw-r--r-- 51.2 KB

README

back to top