Skip to content

Commit c672fa5

Browse files
committed
Fix central directory not containing extra field
1 parent c98af84 commit c672fa5

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/main/php/io/archive/zip/ZipArchiveWriter.class.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ public function addDir(ZipDirEntry $entry) {
112112
);
113113
$this->stream->write(self::FHDR.$info.$name);
114114

115-
$this->dir[$name]= ['info' => $info, 'pointer' => $this->pointer, 'type' => 0x10];
115+
$this->dir[$name]= ['info' => $info, 'pointer' => $this->pointer, 'type' => 0x10, 'extra' => ''];
116116
$this->pointer+= strlen(self::FHDR) + strlen($info) + $nameLength;
117117

118118
return $entry;
@@ -216,7 +216,7 @@ public function addEntry($flags, $compression, $modified, $crc32, $compressed, $
216216
$nameLength && $this->stream->write($name);
217217
$extraLength && $this->stream->write($extra);
218218

219-
$this->dir[$name]= ['info' => $info, 'pointer' => $this->pointer, 'type' => 0x20];
219+
$this->dir[$name]= ['info' => $info, 'pointer' => $this->pointer, 'type' => 0x20, 'extra' => $extra];
220220
$this->pointer+= strlen(self::FHDR) + strlen($info) + $nameLength + $extraLength + $compressed;
221221
}
222222

@@ -244,7 +244,8 @@ public function close() {
244244
"\x01\x00". // internal file attributes
245245
pack('V', $entry['type']).
246246
pack('V', $entry['pointer']).
247-
$name
247+
$name.
248+
$entry['extra']
248249
);
249250
$l+= strlen($s);
250251
$this->stream->write($s);

0 commit comments

Comments
 (0)