API / Minn\Ops / Archive

Archive final class

Minn\Ops\Archive · public/minn/src/Minn/Ops/Archive.php · 105 lines

A zip unpacked the safe way, for the plugin and theme installer and for the engine's own update alike: every entry stays inside its folder (no absolute path, no "..", no backslash, no NUL), none is a symbolic link, there are no more than 20,000 of them, they unpack to no more than 512 MB, and they all sit in exactly one top folder (macOS's __MACOSX noise aside). Nothing is written until every entry has passed.

Uses 1

Constants and properties

constMAX_BYTES = 536870912
privateMAX_ENTRIES = 20000

Public

staticunpackFolder(string $file, string $stage): string#

Unpacks a zip file into a new folder $stage; the path of the one folder the archive held.

staticinspect(string $file): string#

Checks every entry of a zip file without writing anything; the one folder it holds.

staticholds(string $file, string $entry): bool#

Whether a zip file holds an entry by that name.

staticisFolderName(string $name): bool#

A plain folder name: no separators, never "." or "..".

Internals 1

Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.

privateisSymlinkEntry(ZipArchive $archive, int $index): bool#

Whether a zip entry is recorded as a symbolic link (a Unix entry whose mode says so).