diff options
author | TechSneeze <dave@techsneeze.com> | 2022-07-21 21:03:07 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-21 21:03:07 +0300 |
commit | 5901db238cd905f2313caf6379cfd8c00d38cb45 (patch) | |
tree | 35ee4e28617e7f305c4a0c9734cc8993fdeff5ea | |
parent | 80b1574d9c7a7362141cfa24e436a699ff1c800e (diff) | |
parent | 9641d1364b9cd93d0325ca2dccfaa3e50126310f (diff) |
PHP8 compatibility
-rw-r--r-- | dmarcts-report-viewer-common.php | 9 | ||||
-rw-r--r-- | dmarcts-report-viewer-report-data.php | 2 | ||||
-rw-r--r-- | dmarcts-report-viewer-report-list.php | 2 |
3 files changed, 11 insertions, 2 deletions
diff --git a/dmarcts-report-viewer-common.php b/dmarcts-report-viewer-common.php index 57811a1..6d5be4c 100644 --- a/dmarcts-report-viewer-common.php +++ b/dmarcts-report-viewer-common.php @@ -349,6 +349,15 @@ function format_date($date, $format) { return $answer; }; +// null-safe version of htmlspecialchars for PHP 8+ compatibility +// -------------------------------------------------------------------------- +function html_escape($str) { + if ($str == null) { + return null; + } + return htmlspecialchars($str); +} + // Get all configuration options // -------------------------------------------------------------------------- function configure() { diff --git a/dmarcts-report-viewer-report-data.php b/dmarcts-report-viewer-report-data.php index 09ea80e..00f1a68 100644 --- a/dmarcts-report-viewer-report-data.php +++ b/dmarcts-report-viewer-report-data.php @@ -148,7 +148,7 @@ ORDER BY } /* escape html characters after exploring binary values, which will be messed up */ - $row = array_map('htmlspecialchars', $row); + $row = array_map('html_escape', $row); $reportdata[] = " <tr id='line" . $row['id'] . "' class='" . get_dmarc_result($row)['color'] . "' title='DMARC Result: " . get_dmarc_result($row)['result'] . "' onmouseover='highlight(this);' onmouseout='unhighlight(this);' onclick='pin(this);'>"; $reportdata[] = " <td>". $ip. "</td>"; diff --git a/dmarcts-report-viewer-report-list.php b/dmarcts-report-viewer-report-list.php index 806ed8c..ff9a236 100644 --- a/dmarcts-report-viewer-report-list.php +++ b/dmarcts-report-viewer-report-list.php @@ -73,7 +73,7 @@ function tmpl_reportList($reports, $sort) { $reportsum = 0; foreach ($reports as $row) { - $row = array_map('htmlspecialchars', $row); + $row = array_map('html_escape', $row); $reportlist[] = " <tr class='linkable' onclick=\"showReport('" . $row['serial'] . "')\" id='report" . $row['serial'] . "' title='" . $title_message_tr . "'>"; $reportlist[] = " <td class='circle_container'><span class='status_sort_key'>" . get_dmarc_result($row)['status_sort_key'] . "</span></td>"; // Col 0 |