From 9cdc1263000206a42cd069d0125dda8932e0e80d Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sun, 28 Jun 2026 08:32:08 +0900 Subject: fix(php-shim): emit NUL bytes as concatenation in var_export PHP var_export breaks NUL bytes out of single-quoted string literals as `' . "\0" . '` because a raw NUL byte is invalid in PHP source. The shim embedded the raw byte instead, diverging from Composer's generated installed.php (where references can contain NUL). Co-Authored-By: Claude Opus 4.8 (1M context) --- crates/shirabe-php-shim/src/var.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/crates/shirabe-php-shim/src/var.rs b/crates/shirabe-php-shim/src/var.rs index 3fba9d6..f0e55d5 100644 --- a/crates/shirabe-php-shim/src/var.rs +++ b/crates/shirabe-php-shim/src/var.rs @@ -443,6 +443,11 @@ fn var_export_string(s: &str) -> String { let mut out = String::with_capacity(s.len() + 2); out.push('\''); for c in s.chars() { + // PHP var_export breaks NUL bytes out of the single-quoted literal as `' . "\0" . '`. + if c == '\0' { + out.push_str("' . \"\\0\" . '"); + continue; + } if c == '\'' || c == '\\' { out.push('\\'); } -- cgit v1.3.1