| @@ -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 { |
| @@ -68,17 +75,22 @@ | ||
| 68 | 75 | } |
| 69 | 76 | } |
| 70 | 77 | |
| 71 | 78 | class BVRespStream extends BVStream { |
| 79 | + public $bvboundry; | |
| 80 | + | |
| 72 | 81 | function __construct($request) { |
| 73 | 82 | parent::__construct($request); |
| 83 | + $this->bvboundry = $request->bvboundry; | |
| 74 | 84 | } |
| 75 | 85 | |
| 76 | 86 | public function writeChunk($chunk) { |
| 77 | - echo "ckckckckck".$chunk."ckckckckck"; | |
| 87 | + // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- chunk should not be escaped | |
| 88 | + echo $this->bvboundry . "ckckckckck" . $chunk . $this->bvboundry . "ckckckckck"; | |
| 78 | 89 | } |
| 79 | 90 | public function endStream() { |
| 80 | - echo "rerererere"; | |
| 91 | + // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 92 | + echo $this->bvboundry . "rerererere"; | |
| 81 | 93 | |
| 82 | 94 | return array(); |
| 83 | 95 | } |
| 84 | 96 | } |
| @@ -165,9 +177,9 @@ | ||
| 165 | 177 | $mph = array( |
| 166 | 178 | "Content-Disposition" => "form-data; name=bvinfile; filename=data", |
| 167 | 179 | "Content-Type" => "application/octet-stream" |
| 168 | 180 | ); |
| 169 | - $rnd = rand(100000, 999999); | |
| 181 | + $rnd = rand(100000, 999999); // phpcs:ignore WordPress.WP.AlternativeFunctions.rand_rand | |
| 170 | 182 | $this->boundary = "----".$rnd; |
| 171 | 183 | $prologue = "--".$this->boundary."\r\n"; |
| 172 | 184 | foreach($mph as $key=>$val) { |
| 173 | 185 | $prologue .= $key.":".$val."\r\n"; |
| @@ -240,5 +252,6 @@ | ||
| 240 | 252 | } |
| 241 | 253 | return $response; |
| 242 | 254 | } |
| 243 | 255 | } |
| 256 | +// phpcs:enable | |
| 244 | 257 | endif; |