diff --git a/pub/errors/processor.php b/pub/errors/processor.php index 0cb182700856c..14432fa9dfab7 100644 --- a/pub/errors/processor.php +++ b/pub/errors/processor.php @@ -29,6 +29,11 @@ class Processor const ERROR_DIR = 'pub/errors'; const NUMBER_SYMBOLS_IN_SUBDIR_NAME = 2; + /** + * @var string + */ + private const REPORT_EXECUTION_GUARD = ''; + /** * Page title * @@ -518,7 +523,11 @@ public function saveReport(array $reportData): string } $this->_setReportData($reportData); - @file_put_contents($this->_reportFile, $this->serializer->serialize($reportData). PHP_EOL); + $reportData = $this->sanitizeReportData($reportData); + @file_put_contents( + $this->_reportFile, + self::REPORT_EXECUTION_GUARD . PHP_EOL . $this->serializer->serialize($reportData) . PHP_EOL + ); if (isset($reportData['skin']) && self::DEFAULT_SKIN != $reportData['skin']) { $this->_setSkin($reportData['skin']); @@ -528,6 +537,38 @@ public function saveReport(array $reportData): string return $this->reportUrl; } + /** + * Neutralize PHP open tags inside report values. + * + * @param array $data + * @return array + */ + private function sanitizeReportData(array $data): array + { + array_walk_recursive($data, static function (&$value) { + if (is_string($value)) { + $value = str_replace('reportId = $reportId; $this->_reportFile = $reportFile; - $this->_setReportData($this->serializer->unserialize(file_get_contents($this->_reportFile))); + $this->_setReportData( + $this->serializer->unserialize($this->readReportFile($this->_reportFile)) + ); } catch (\RuntimeException $e) { $this->redirectToBaseUrl(); }