X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fapi%2FApiCSPReport.php;h=a4631d6f34597aea1fd8e1e0cd0cc024d235e049;hb=58b05b9854c490791686bc34a7270e5c3f6dde5c;hp=4139019ccf0a4d73faa94f03473c2e8730fa797a;hpb=30f28501243ba58faf4063b701cf3148bd1d1280;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/api/ApiCSPReport.php b/includes/api/ApiCSPReport.php index 4139019ccf..a4631d6f34 100644 --- a/includes/api/ApiCSPReport.php +++ b/includes/api/ApiCSPReport.php @@ -63,9 +63,9 @@ class ApiCSPReport extends ApiBase { /** * Log CSP report, with a different severity depending on $flags - * @param $flags Array Flags for this report - * @param $logLine String text of log entry - * @param $context Array logging context + * @param array $flags Flags for this report + * @param string $logLine text of log entry + * @param array $context logging context */ private function logReport( $flags, $logLine, $context ) { if ( in_array( 'false-positive', $flags ) ) { @@ -80,8 +80,8 @@ class ApiCSPReport extends ApiBase { /** * Get extra notes about the report. * - * @param $report Array The CSP report - * @return Array + * @param array $report The CSP report + * @return array */ private function getFlags( $report ) { $reportOnly = $this->getParameter( 'reportonly' ); @@ -115,7 +115,7 @@ class ApiCSPReport extends ApiBase { $req = $this->getRequest(); $contentType = $req->getHeader( 'content-type' ); if ( $contentType !== 'application/json' - && $contentType !=='application/csp-report' + && $contentType !== 'application/csp-report' ) { $this->error( 'wrongformat', __METHOD__ ); } @@ -155,9 +155,9 @@ class ApiCSPReport extends ApiBase { /** * Get text of log line. * - * @param $flags Array of additional markers for this report - * @param $report Array the csp report - * @return String Text to put in log + * @param array $flags of additional markers for this report + * @param array $report the csp report + * @return string Text to put in log */ private function generateLogLine( $flags, $report ) { $flagText = ''; @@ -177,8 +177,8 @@ class ApiCSPReport extends ApiBase { /** * Stop processing the request, and output/log an error * - * @param $code String error code - * @param $method String method that made error + * @param string $code error code + * @param string $method method that made error * @throws ApiUsageException Always */ private function error( $code, $method ) { @@ -186,9 +186,9 @@ class ApiCSPReport extends ApiBase { 'method' => $method, 'user-agent' => $this->getRequest()->getHeader( 'user-agent' ) ] ); - // 500 so it shows up in browser's developer console. + // Return 400 on error for user agents to display, e.g. to the console. $this->dieWithError( - [ 'apierror-csp-report', wfEscapeWikiText( $code ) ], 'cspreport-' . $code, [], 500 + [ 'apierror-csp-report', wfEscapeWikiText( $code ) ], 'cspreport-' . $code, [], 400 ); }