Category
stdlib · php-src-strict
Problem
When the CSV escape character equals the enclosure (", PHP 8.4+ default for str_getcsv() / fgetcsv()), this compiler stops parsing after the first field. Zend/php-src returns all fields with doubled-quote unescaping inside enclosures.
VM and JIT share ext/standard/VmCsv::parseLine() — one PHP fix covers all backends.
php-src reference
Repro
Run inside ./script/docker-exec.sh:
cat > /tmp/repro_csv_escape_quote.php <<'PHP'
<?php
$line = 'a,"b""c",d';
var_dump(str_getcsv($line, ',', '"', '"'));
$f = fopen('php://memory', 'r+');
fwrite($f, $line . "\n");
rewind($f);
var_dump(fgetcsv($f, 0, ',', '"', '"'));
fclose($f);
PHP
php /tmp/repro_csv_escape_quote.php
php bin/vm.php /tmp/repro_csv_escape_quote.php
| Engine |
str_getcsv(..., '"', '"') |
| Zend PHP 8.2+ |
['a', 'b"c', 'd'] |
| VM (today) |
['a'] |
Verified 2026-06-17.
Scope (PHP-in-PHP)
| Layer |
Path |
| Parser SSOT |
ext/standard/VmCsv.php — fix doubled-enclosure branch when $esc === $enc |
| VM |
ext/standard/str_getcsv.php, ext/standard/fgetcsv.php (delegate to VmCsv) |
| JIT/AOT |
lib/JIT/Builtin/StringStrGetcsvJit.php, StringFgetcsvJit.php (reuse VmCsv) |
| Tests |
test/compliance/cases/stdlib/str_getcsv_escape_enclosure.phpt |
No new C runtime — parser logic stays in PHP (VmCsv).
Done when (php-src-strict)
Related
Category
stdlib· php-src-strictProblem
When the CSV escape character equals the enclosure (
", PHP 8.4+ default forstr_getcsv()/fgetcsv()), this compiler stops parsing after the first field. Zend/php-src returns all fields with doubled-quote unescaping inside enclosures.VM and JIT share
ext/standard/VmCsv::parseLine()— one PHP fix covers all backends.php-src reference
ext/standard/file.c—php_fgetcsv()/php_str_getcsv()state machine when escape char equals enclosureext/standard/file.c—fgetcsv()shares parserRepro
Run inside
./script/docker-exec.sh:str_getcsv(..., '"', '"')['a', 'b"c', 'd']['a']Verified 2026-06-17.
Scope (PHP-in-PHP)
ext/standard/VmCsv.php— fix doubled-enclosure branch when$esc === $encext/standard/str_getcsv.php,ext/standard/fgetcsv.php(delegate to VmCsv)lib/JIT/Builtin/StringStrGetcsvJit.php,StringFgetcsvJit.php(reuse VmCsv)test/compliance/cases/stdlib/str_getcsv_escape_enclosure.phptNo new C runtime — parser logic stays in PHP (
VmCsv).Done when (php-src-strict)
['a', 'b"c', 'd']on VM and JIT/AOT'\\') path unchangedRelated