[Bug 1979147] [NEW] folded file names in MIME headers are interpreted incorrectly by part.get_filename()

Jonathan Kamens 1979147 at bugs.launchpad.net
Sun Jun 19 19:56:57 UTC 2022


Public bug reported:

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)

** Affects: python
     Importance: Unknown
         Status: Unknown

** Affects: python3.10 (Ubuntu)
     Importance: Undecided
         Status: New


** Tags: amd64 apport-bug jammy

** Bug watch added: github.com/python/cpython/issues #83221
   https://github.com/python/cpython/issues/83221

** Also affects: python via
   https://github.com/python/cpython/issues/83221
   Importance: Unknown
       Status: Unknown

-- 
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to python3.10 in Ubuntu.
https://bugs.launchpad.net/bugs/1979147

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

Status in Python:
  Unknown
Status in python3.10 package in Ubuntu:
  New

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)

To manage notifications about this bug go to:
https://bugs.launchpad.net/python/+bug/1979147/+subscriptions




More information about the foundations-bugs mailing list