| @@ -1,6 +1,13 @@ | ||
| 1 | 1 | <?php |
| 2 | - | |
| 2 | +// phpcs:disable WordPress.WP.AlternativeFunctions.file_system_operations_fread | |
| 3 | +// phpcs:disable WordPress.WP.AlternativeFunctions.file_system_operations_fwrite | |
| 4 | +// phpcs:disable WordPress.WP.AlternativeFunctions.file_system_operations_fsockopen | |
| 5 | +// We use php method like fread, fwrite to read only a portion of a file, we don't have a direct method for partial reads since WP_Filesystem doesn't support a direct equivalent to fread, fwrite. | |
| 6 | +// The entire file deals with custom stream handling | |
| 7 | +// We need direct socket/file operations for this functionality | |
| 8 | +// WordPress filesystem alternatives wouldn't work for this use case | |
| 9 | +// It's better to disable these specific rules at file level than adding individual ignore comments | |
| 3 | 10 | if (!defined('ABSPATH')) exit; |
| 4 | 11 | if (!class_exists('BVRespStream')) : |
| 5 | 12 | |
| 6 | 13 | class BVStream extends BVCallbackBase { |
| @@ -76,11 +83,13 @@ | ||
| 76 | 83 | $this->bvboundry = $request->bvboundry; |
| 77 | 84 | } |
| 78 | 85 | |
| 79 | 86 | public function writeChunk($chunk) { |
| 87 | + // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- chunk should not be escaped | |
| 80 | 88 | echo $this->bvboundry . "ckckckckck" . $chunk . $this->bvboundry . "ckckckckck"; |
| 81 | 89 | } |
| 82 | 90 | public function endStream() { |
| 91 | + // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 83 | 92 | echo $this->bvboundry . "rerererere"; |
| 84 | 93 | |
| 85 | 94 | return array(); |
| 86 | 95 | } |
| @@ -168,9 +177,9 @@ | ||
| 168 | 177 | $mph = array( |
| 169 | 178 | "Content-Disposition" => "form-data; name=bvinfile; filename=data", |
| 170 | 179 | "Content-Type" => "application/octet-stream" |
| 171 | 180 | ); |
| 172 | - $rnd = rand(100000, 999999); | |
| 181 | + $rnd = rand(100000, 999999); // phpcs:ignore WordPress.WP.AlternativeFunctions.rand_rand | |
| 173 | 182 | $this->boundary = "----".$rnd; |
| 174 | 183 | $prologue = "--".$this->boundary."\r\n"; |
| 175 | 184 | foreach($mph as $key=>$val) { |
| 176 | 185 | $prologue .= $key.":".$val."\r\n"; |
| @@ -243,5 +252,6 @@ | ||
| 243 | 252 | } |
| 244 | 253 | return $response; |
| 245 | 254 | } |
| 246 | 255 | } |
| 256 | +// phpcs:enable | |
| 247 | 257 | endif; |