diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-07-05 14:51:32 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-07-05 14:51:32 +0900 |
| commit | a851d86b4546dae5fec9e0f046c29d2f2bedb857 (patch) | |
| tree | fc8ff76b1f3f3d098cb5e6c6a358028a245d8eda /crates/shirabe-php-shim/src | |
| parent | 23860a736f539064a64284a673a1b0e69d24e980 (diff) | |
| download | php-shirabe-a851d86b4546dae5fec9e0f046c29d2f2bedb857.tar.gz php-shirabe-a851d86b4546dae5fec9e0f046c29d2f2bedb857.tar.zst php-shirabe-a851d86b4546dae5fec9e0f046c29d2f2bedb857.zip | |
feat(remote-filesystem): support file:// URLs in get_remote_contents
get_remote_contents was a full stub always returning None, so any
file:// download raised a TransportException. Read local files
directly for the file scheme, mirroring PHP's file_get_contents
transparently handling the file:// stream wrapper. Also fixes
file_get_contents5 to strip the file:// prefix like the 0-arg
variant already did.
Diffstat (limited to 'crates/shirabe-php-shim/src')
| -rw-r--r-- | crates/shirabe-php-shim/src/fs.rs | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/crates/shirabe-php-shim/src/fs.rs b/crates/shirabe-php-shim/src/fs.rs index e58623a..a20e956 100644 --- a/crates/shirabe-php-shim/src/fs.rs +++ b/crates/shirabe-php-shim/src/fs.rs @@ -881,7 +881,9 @@ pub fn file_get_contents5( ) -> Option<String> { // TODO(phase-d): the stream $context and FILE_USE_INCLUDE_PATH are ignored; only $offset and // $length are applied (to the file read from the local filesystem). - let bytes = std::fs::read(_path).ok()?; + // PHP supports the file:// stream wrapper; strip it to read the local file. + let path = _path.strip_prefix("file://").unwrap_or(_path); + let bytes = std::fs::read(path).ok()?; let len = bytes.len() as i64; let start = if _offset < 0 { (len + _offset).max(0) |
