diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-06-28 08:32:08 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-06-28 08:32:08 +0900 |
| commit | 9cdc1263000206a42cd069d0125dda8932e0e80d (patch) | |
| tree | 05cf96136acce3a8f2d70239c362fd15ecf83b3b /crates/shirabe-php-shim/src | |
| parent | 0bf96f5de11555ddfdcde81c0a27869afeaf5832 (diff) | |
| download | php-shirabe-9cdc1263000206a42cd069d0125dda8932e0e80d.tar.gz php-shirabe-9cdc1263000206a42cd069d0125dda8932e0e80d.tar.zst php-shirabe-9cdc1263000206a42cd069d0125dda8932e0e80d.zip | |
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) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe-php-shim/src')
| -rw-r--r-- | crates/shirabe-php-shim/src/var.rs | 5 |
1 files changed, 5 insertions, 0 deletions
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('\\'); } |
