folded file names in MIME headers are interpreted incorrectly by part.get_filename()

Bug #1979147 reported by Jonathan Kamens
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Python
Unknown
Unknown
python3.10 (Ubuntu)
New
Undecided
Unassigned

Bug Description

If the filename in the header field of a MIME attachment is folded, the `get_filename()` function doesn't return the correct file name. It's supposed to ignore folded CRLFs but doesn't.

Script which illustrates the bug:

#!/usr/bin/env python3

import email

message = email.message_from_string("""\
MIME-Version: 1.0
Content-Type: text/plain; name="This File Name Is
 Folded.pdf"
Content-Disposition: attachment; filename="This File Name Is
 Folded.pdf"
Content-Transfer-Encoding: 8bit

Foo
""")

print(message.get_filename())

ProblemType: Bug
DistroRelease: Ubuntu 22.04
Package: libpython3.10-minimal 3.10.4-3
ProcVersionSignature: Ubuntu 5.15.0-39.42-generic 5.15.35
Uname: Linux 5.15.0-39-generic x86_64
ApportVersion: 2.20.11-0ubuntu82.1
Architecture: amd64
CasperMD5CheckResult: unknown
CurrentDesktop: ubuntu:GNOME
Date: Sun Jun 19 15:49:23 2022
InstallationDate: Installed on 2019-01-02 (1264 days ago)
InstallationMedia: Ubuntu 18.10 "Cosmic Cuttlefish" - Release amd64 (20181017.3)
SourcePackage: python3.10
UpgradeStatus: Upgraded to jammy on 2022-02-20 (118 days ago)

Revision history for this message
Jonathan Kamens (jik) wrote :
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.