From 07389d12aa52d147b4dc37c8fef4dceb3bd0f5c3 Mon Sep 17 00:00:00 2001 From: William Desportes Date: Wed, 1 May 2019 20:31:40 +0200 Subject: [PATCH] Fixed error reporting (current web page url, JS file name sanitization) - Added tests on master branch - Added support for js/*.js files - Added support for slashes and dots in file paths - Added back support for 'url' (the current webpage) All js files where reported as 'index.php' now they are reported as their real name Signed-off-by: William Desportes --- js/error_report.js | 2 +- libraries/classes/ErrorReport.php | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/js/error_report.js b/js/error_report.js index 466bf96099..c1257c9763 100644 --- a/js/error_report.js +++ b/js/error_report.js @@ -224,7 +224,7 @@ var ErrorReport = { 'server': PMA_commonParams.get('server'), 'ajax_request': true, 'exception': exception, - 'current_url': window.location.href, + 'url': window.location.href, 'exception_type': 'js' }; if (AJAX.scriptHandler._scripts.length > 0) { diff --git a/libraries/classes/ErrorReport.php b/libraries/classes/ErrorReport.php index 2d0321c350..3ae5aab365 100644 --- a/libraries/classes/ErrorReport.php +++ b/libraries/classes/ErrorReport.php @@ -99,6 +99,11 @@ class ErrorReport $exception["uri"] = $uri; $report["script_name"] = $scriptName; unset($exception["url"]); + } else if (isset($_POST["url"])) { + list($uri, $scriptName) = $this->sanitizeUrl($_POST["url"]); + $exception["uri"] = $uri; + $report["script_name"] = $scriptName; + unset($_POST["url"]); } else { $report["script_name"] = null; } @@ -175,7 +180,7 @@ class ErrorReport } // get script name - preg_match("<([a-zA-Z\-_\d]*\.php)$>", $components["path"], $matches); + preg_match("<([a-zA-Z\-_\d\.]*\.php|js\/[a-zA-Z\-_\d\/\.]*\.js)$>", $components["path"], $matches); if (count($matches) < 2) { $scriptName = 'index.php'; } else {