classification
Title: wrong FNAME in tarfile if tgz extension is used
Type: Stage:
Components: Library (Lib) Versions: Python 3.11, Python 3.10, Python 3.9, Python 3.8, Python 3.7, Python 3.6
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: maciej.mm.misiak
Priority: normal Keywords:

Created on 2021-06-23 06:55 by maciej.mm.misiak, last changed 2021-06-23 06:55 by maciej.mm.misiak.

Messages (1)
msg396382 - (view) Author: Maciej Misiak (maciej.mm.misiak) Date: 2021-06-23 06:55
This code is incomplete:

def _init_write_gz(self):
...
    if self.name.endswith(".gz"):
        self.name = self.name[:-3]
    # RFC1952 says we must use ISO-8859-1 for the FNAME field.
    self.__write(self.name.encode("iso-8859-1", "replace") + NUL)

If it is used in following way '.gz' is stripped properly and FNAME='somefile.tar':
    tarfile.open('somefile.tar.gz', 'w:gz')
but with 
    tarfile.open('somefile.tgz', 'w:gz')

FNAME is incorrectly prepared as somefile.tgz
History
Date User Action Args
2021-06-23 06:55:14maciej.mm.misiakcreate