summaryrefslogtreecommitdiff
path: root/Zend/tests/bug78406.phpt
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2019-08-13 10:22:32 +0200
committerNikita Popov <nikita.ppv@gmail.com>2019-08-13 10:22:32 +0200
commitb01824e596dd11d075d1f2c9af364d2fdabc4d17 (patch)
treee363fe78fad9383dbb8669ad296d74a7a09f6a83 /Zend/tests/bug78406.phpt
parentbdf3fa8c3e171c32635a6df0d5b544629eecb951 (diff)
downloadphp-git-b01824e596dd11d075d1f2c9af364d2fdabc4d17.tar.gz
Fixed bug #78406
Diffstat (limited to 'Zend/tests/bug78406.phpt')
-rw-r--r--Zend/tests/bug78406.phpt44
1 files changed, 44 insertions, 0 deletions
diff --git a/Zend/tests/bug78406.phpt b/Zend/tests/bug78406.phpt
new file mode 100644
index 0000000000..64fd2a1945
--- /dev/null
+++ b/Zend/tests/bug78406.phpt
@@ -0,0 +1,44 @@
+--TEST--
+Bug #78406: Broken file includes with user-defined stream filters
+--FILE--
+<?php
+
+echo "bug\n"; // Should be transformed by filter on second include
+
+if (!class_exists(SampleFilter::class)) {
+ class SampleFilter extends php_user_filter
+ {
+ private $data = '';
+
+ public function filter($in, $out, &$consumed, $closing)
+ {
+ while ($bucket = stream_bucket_make_writeable($in))
+ {
+ $this->data .= $bucket->data;
+ }
+
+ if ($closing || feof($this->stream))
+ {
+ $consumed = strlen($this->data);
+
+ $this->data = str_replace('bug', 'feature', $this->data);
+
+ $bucket = stream_bucket_new($this->stream, $this->data);
+ stream_bucket_append($out, $bucket);
+
+ return PSFS_PASS_ON;
+ }
+
+ return PSFS_FEED_ME;
+ }
+ }
+ stream_filter_register('sample.filter', SampleFilter::class);
+ $uri = 'php://filter/read=sample.filter/resource='. __FILE__;
+
+ include $uri; // We expect one more "feature" output at line 3
+}
+
+?>
+--EXPECT--
+bug
+feature