Skip to content

PAX typeFlag 'x' #18

Open
Open
@ovidiul

Description

@ovidiul

I have encountered an issue when adding filename in format "._4слайд-150x150.jpg" , the linux tar utility would mark them with typeFlag x, which is similar to the LongLink typeFlag L. This breaks the archive extraction and the generated error would be "Header does not match it's checksum for"

Since the TAR class supports ustar format, it seems it's bound to support pax type as file, so a quick way for fixing this would be to replace this code

// Handle Long-Link entries from GNU Tar
        if ($return['typeflag'] == 'L' ) {
            // following data block(s) is the filename
            $filename = trim($this->readbytes(ceil($header['size'] / 512) * 512));
            // next block is the real header
            $block  = $this->readbytes(512);
            $return = $this->parseHeader($block);

            // overwrite the filename
		$return['filename'] = $filename;
        }

with

// Handle Long-Link entries from GNU Tar
        if ($return['typeflag'] == 'L' || $return['typeflag'] == 'x') {
            // following data block(s) is the filename
            $filename = trim($this->readbytes(ceil($header['size'] / 512) * 512));
            // next block is the real header
            $block  = $this->readbytes(512);
            $return = $this->parseHeader($block);

            // overwrite the filename
            if($return['typeflag'] == 'L')
            {
				$return['filename'] = $filename;
			}
        }

in the protected function parseHeader($block)

I have tested this and it works fine from processing records with typeFlag x , should i do a pull request?

I am attaching as well the tgz archive i've used for testing
test.tgz.zip

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions