This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | declare(strict_types=1); |
||
3 | |||
4 | namespace Genkgo\Mail\Stream; |
||
5 | |||
6 | use Genkgo\Mail\StreamInterface; |
||
7 | |||
8 | final class QuotedPrintableDecodedStream implements StreamInterface |
||
9 | { |
||
10 | /** |
||
11 | * @var StreamInterface |
||
12 | */ |
||
13 | private $decoratedStream; |
||
14 | |||
15 | /** |
||
16 | * @var resource |
||
17 | */ |
||
18 | private $filter; |
||
19 | |||
20 | /** |
||
21 | * @param resource $resource |
||
22 | */ |
||
23 | 10 | public function __construct($resource) |
|
24 | { |
||
25 | 10 | $this->decoratedStream = new ResourceStream($resource); |
|
26 | |||
27 | 10 | $this->applyFilter(); |
|
28 | 10 | } |
|
29 | |||
30 | /** |
||
31 | * @param string $string |
||
32 | * @return QuotedPrintableDecodedStream |
||
33 | */ |
||
34 | 10 | public static function fromString(string $string): QuotedPrintableDecodedStream |
|
35 | { |
||
36 | 10 | $resource = \fopen('php://memory', 'r+'); |
|
37 | 10 | if ($resource === false) { |
|
38 | throw new \UnexpectedValueException('Cannot open php://memory for writing'); |
||
39 | } |
||
40 | |||
41 | 10 | \fwrite($resource, $string); |
|
42 | 10 | return new self($resource); |
|
43 | } |
||
44 | |||
45 | 10 | private function applyFilter(): void |
|
46 | { |
||
47 | 10 | $filter = \stream_filter_prepend( |
|
48 | 10 | $this->decoratedStream->detach(), |
|
49 | 10 | 'convert.quoted-printable-decode', |
|
50 | 10 | STREAM_FILTER_READ |
|
51 | ); |
||
52 | |||
53 | 10 | if ($filter === false) { |
|
54 | throw new \UnexpectedValueException('Cannot append filter to stream'); |
||
55 | } |
||
56 | |||
57 | 10 | $this->filter = $filter; |
|
58 | 10 | } |
|
59 | |||
60 | 5 | private function removeFilter(): void |
|
61 | { |
||
62 | 5 | if ($this->filter !== null) { |
|
63 | 5 | \stream_filter_remove($this->filter); |
|
64 | } |
||
65 | 5 | } |
|
66 | |||
67 | /** |
||
68 | * @return string |
||
69 | */ |
||
70 | 4 | public function __toString(): string |
|
71 | { |
||
72 | 4 | $this->rewind(); |
|
73 | 4 | return $this->decoratedStream->__toString(); |
|
74 | } |
||
75 | |||
76 | public function close(): void |
||
77 | { |
||
78 | $this->decoratedStream->close(); |
||
79 | } |
||
80 | |||
81 | /** |
||
82 | * @return mixed |
||
83 | */ |
||
84 | public function detach() |
||
85 | { |
||
86 | return $this->decoratedStream->detach(); |
||
87 | } |
||
88 | |||
89 | /** |
||
90 | * @return int|null |
||
91 | */ |
||
92 | 1 | public function getSize(): ?int |
|
93 | { |
||
94 | 1 | return null; |
|
95 | } |
||
96 | |||
97 | /** |
||
98 | * @return int |
||
99 | * @throws \RuntimeException |
||
100 | */ |
||
101 | 1 | public function tell(): int |
|
102 | { |
||
103 | 1 | return $this->decoratedStream->tell(); |
|
104 | } |
||
105 | |||
106 | /** |
||
107 | * @return bool |
||
108 | */ |
||
109 | public function eof(): bool |
||
110 | { |
||
111 | return $this->decoratedStream->eof(); |
||
112 | } |
||
113 | |||
114 | /** |
||
115 | * @return bool |
||
116 | */ |
||
117 | public function isSeekable(): bool |
||
118 | { |
||
119 | return false; |
||
120 | } |
||
121 | |||
122 | /** |
||
123 | * @param int $offset |
||
124 | * @param int $whence |
||
125 | * @return int |
||
126 | */ |
||
127 | 1 | public function seek(int $offset, int $whence = SEEK_SET): int |
|
128 | { |
||
129 | 1 | return -1; |
|
130 | } |
||
131 | |||
132 | /** |
||
133 | * @return bool |
||
134 | */ |
||
135 | 5 | public function rewind(): bool |
|
136 | { |
||
137 | 5 | $this->removeFilter(); |
|
138 | 5 | if (!$this->decoratedStream->rewind()) { |
|
139 | return false; |
||
140 | } |
||
141 | |||
142 | 5 | $this->applyFilter(); |
|
143 | 5 | return true; |
|
144 | } |
||
145 | |||
146 | /** |
||
147 | * @return bool |
||
148 | */ |
||
149 | 1 | public function isWritable(): bool |
|
150 | { |
||
151 | 1 | return false; |
|
152 | } |
||
153 | |||
154 | /** |
||
155 | * @param string $string |
||
156 | * @return int |
||
157 | */ |
||
158 | 1 | public function write($string): int |
|
159 | { |
||
160 | 1 | throw new \RuntimeException('Cannot write to stream'); |
|
161 | } |
||
162 | |||
163 | /** |
||
164 | * @return bool |
||
165 | */ |
||
166 | public function isReadable(): bool |
||
167 | { |
||
168 | return true; |
||
169 | } |
||
170 | |||
171 | /** |
||
172 | * @param int $length |
||
173 | * @return string |
||
174 | */ |
||
175 | 2 | public function read(int $length): string |
|
176 | { |
||
177 | 2 | return $this->decoratedStream->read($length); |
|
178 | } |
||
179 | |||
180 | /** |
||
181 | * @return string |
||
182 | */ |
||
183 | 3 | public function getContents(): string |
|
184 | { |
||
185 | 3 | return $this->decoratedStream->getContents(); |
|
186 | } |
||
187 | |||
188 | /** |
||
189 | * @param array<int, string> $keys |
||
190 | * @return array<string, mixed> |
||
0 ignored issues
–
show
|
|||
191 | */ |
||
192 | public function getMetadata(array $keys = []): array |
||
193 | { |
||
194 | return $this->decoratedStream->getMetadata(); |
||
195 | } |
||
196 | } |
||
197 |
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.