Merge "Revert "Introduce Special:RedirectExternal""
[lhc/web/wiklou.git] / includes / api / ApiCSPReport.php
index 42d1093..6271128 100644 (file)
@@ -47,7 +47,7 @@ class ApiCSPReport extends ApiBase {
 
                $this->verifyPostBodyOk();
                $report = $this->getReport();
-               $flags = $this->getFlags( $report );
+               $flags = $this->getFlags( $report, $userAgent );
 
                $warningText = $this->generateLogLine( $flags, $report );
                $this->logReport( $flags, $warningText, [
@@ -81,9 +81,10 @@ class ApiCSPReport extends ApiBase {
         * Get extra notes about the report.
         *
         * @param array $report The CSP report
+        * @param string $userAgent
         * @return array
         */
-       private function getFlags( $report ) {
+       private function getFlags( $report, $userAgent ) {
                $reportOnly = $this->getParameter( 'reportonly' );
                $source = $this->getParameter( 'source' );
                $falsePositives = $this->getConfig()->get( 'CSPFalsePositiveUrls' );
@@ -137,7 +138,7 @@ class ApiCSPReport extends ApiBase {
        /**
         * Get the report from post body and turn into associative array.
         *
-        * @return Array
+        * @return array
         */
        private function getReport() {
                $postBody = $this->getRequest()->getRawInput();
@@ -175,8 +176,8 @@ class ApiCSPReport extends ApiBase {
                        $flagText = '[' . implode( ', ', $flags ) . ']';
                }
 
-               $blockedFile = isset( $report['blocked-uri'] ) ? $report['blocked-uri'] : 'n/a';
-               $page = isset( $report['document-uri'] ) ? $report['document-uri'] : 'n/a';
+               $blockedFile = $report['blocked-uri'] ?? 'n/a';
+               $page = $report['document-uri'] ?? 'n/a';
                $line = isset( $report['line-number'] ) ? ':' . $report['line-number'] : '';
                $warningText = $flagText .
                        ' Received CSP report: <' . $blockedFile .