Skip to content

Stdlib: honor allow_url_include for script-style data:// opens (#32104) - #32126

Merged
PurHur merged 1 commit into
masterfrom
agent/stdlib-32104-allow-url-include-data
Aug 18, 2026
Merged

Stdlib: honor allow_url_include for script-style data:// opens (#32104)#32126
PurHur merged 1 commit into
masterfrom
agent/stdlib-32104-allow-url-include-data

Conversation

@PurHur

@PurHur PurHur commented Aug 18, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add VmStreamIncludeOpenPolicy shared by VM and JIT/AOT for script/include-style stream opens (php-src STREAM_OPEN_FOR_INCLUDE parity)
  • Gate php_strip_whitespace(), highlight_file(), and show_source() on allow_url_include for URL wrappers like data://
  • Leave file_get_contents() / file() on the allow_url_fopen path unchanged

php-src reference: ext/standard/basic_functions.c (php_strip_whitespace, highlight_file), main/streams/streams.c

Test plan

  • ./script/phpunit.sh --filter 'StreamIncludeOpenPolicyTest' → OK (3 tests, 6 assertions)
  • ./script/docker-exec.sh -- bash -lc 'php bin/vm.php test/repro/maintainer_gap_strip_whitespace_data.php'
    • strip '' + 2 Zend-shaped warnings; fgc still returns payload
  • ./script/docker-exec.sh -- bash -lc 'php bin/vm.php test/repro/maintainer_gap_highlight_file_data.php'
    • highlight_file/show_source false + 3 warnings each; fgc still returns payload
  • ./script/docker-exec.sh -- bash -lc 'php bin/jit.php test/repro/maintainer_gap_strip_whitespace_data.php' → same as VM
  • ./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && tmp=$(mktemp -d) && php bin/compile.php -o "$tmp/strip.bin" test/repro/maintainer_gap_strip_whitespace_data.php && "$tmp/strip.bin"'
  • ./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && tmp=$(mktemp -d) && php bin/compile.php -o "$tmp/hl.bin" test/repro/maintainer_gap_highlight_file_data.php && "$tmp/hl.bin"'
    • AOT: highlight_file/show_source blocked with 3 warnings each
  • Compliance phpt not run via PHPUnit harness this run (manual VM output matches --EXPECT--)
  • AOT standalone file_get_contents('data://…') returns false (pre-existing thin-runtime gap; VM/JIT fgc OK)

Closes #32104.

Made with Cursor

php_strip_whitespace(), highlight_file(), and show_source() now match
php-src by refusing URL wrappers when allow_url_include is off, while
file_get_contents() keeps using allow_url_fopen.

Co-authored-by: Cursor <cursoragent@cursor.com>
@PurHur
PurHur merged commit 213af36 into master Aug 18, 2026
1 check failed
@PurHur
PurHur deleted the agent/stdlib-32104-allow-url-include-data branch August 18, 2026 10:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Stdlib: php_strip_whitespace/highlight_file/show_source ignore allow_url_include for data:// (ext/standard/basic_functions.c)

1 participant