summaryrefslogtreecommitdiff
path: root/Zend/tests/bug78406.phpt
blob: 64fd2a1945085df6e8623976d459f54c8ebcf8bd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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