Documentation
¶
Overview ¶
Package files provides the filesystem shims phpscript exposes to PHP: path helpers, reads, writes, streams, and the uploaded-file functions that go with $_FILES. They are grouped here rather than in stdlib because they are the one part of the standard library bound to a directory on the host, and because a host that runs untrusted scripts may want to leave them out.
Go's fs.FS is read-only, so writes (fopen/fwrite/mkdir) use the os package against the same root; the runner's include resolution still uses the fs.FS abstraction passed to runner.New.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Register ¶
Register installs the filesystem shims rooted at the process working directory. A host serving scripts out of a project directory binds that instead, with RegisterRoot.
func RegisterRoot ¶
RegisterRoot installs the filesystem shims rooted at dir. A relative path from PHP resolves against dir and cannot climb out of it; an absolute path is taken as the script wrote it and is not confined.
Writes are held to the runtime's writable_paths when it configures any, which is what confines an absolute path: naming one does not make it writable.
It replaces whatever root was installed before it, so a host calls it after stdlib.Register (stdlib.RegisterFS does exactly that).
func Within ¶
Within reports whether name is dir or something beneath it. The separator is what keeps a sibling out: /srv/site/uploads-old is not under /srv/site/upload even though the string starts the same way.
It is exported because a host has the same question to answer: a server that serves a writable directory has to know not to execute the PHP a script may have written into it.
func WritableRoots ¶
WritableRoots resolves the configured writable_paths against the directory the shims are bound to. An entry is a path inside the project, so uploads is the project's uploads directory and public/uploads is the one below the document root; an absolute entry is taken as given, for a host that writes somewhere outside its own tree on purpose.
Types ¶
This section is empty.