From c2f92936e31182abf0034abedf58b343c72eccfe Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Mon, 4 Jan 2016 17:09:24 +0100 Subject: [PATCH] shorten escaping code --- www/index.php | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/www/index.php b/www/index.php index 1670931..a81f774 100644 --- a/www/index.php +++ b/www/index.php @@ -161,7 +161,7 @@ function getDisplayItem($line) $line = preg_replace('#\s+#', ' ', $line); return '' . 'Display' - . '' . utf8_decode(htmlspecialchars($line)) . '' + . '' . nox_esc($line) . '' . ''; } @@ -170,9 +170,9 @@ function getDirItem($title, $urlPath) global $host1, $host2; return '' . 'Dir' - . '' . utf8_decode(htmlspecialchars($title)) . '' - . '' . $host1 . utf8_decode(htmlspecialchars($urlPath)) . '' - . '' . $host2 . utf8_decode(htmlspecialchars($urlPath)) . '' + . '' . nox_esc($title) . '' + . '' . $host1 . nox_esc($urlPath) . '' + . '' . $host2 . nox_esc($urlPath) . '' . ''; } @@ -180,9 +180,9 @@ function getEpisodeItem($title, $fullUrl, $desc, $type) { return '' . 'ShowEpisode' - . '' . utf8_decode(htmlspecialchars($title)) . '' + . '' . nox_esc($title) . '' . '' . htmlspecialchars($fullUrl) . '' - . '' . utf8_decode(htmlspecialchars($desc)) . '' + . '' . nox_esc($desc) . '' . '' . $type . '' . ''; } @@ -192,8 +192,8 @@ function getPodcastItem($title, $urlPath) global $host1; return '' . 'ShowOnDemand' - . '' . utf8_decode(htmlspecialchars($title)) . '' - . '' . $host1 . utf8_decode(htmlspecialchars($urlPath)) . '' + . '' . nox_esc($title) . '' + . '' . $host1 . nox_esc($urlPath) . '' . ''; } @@ -201,7 +201,7 @@ function getMessageItem($msg) { return '' . 'Message' - . '' . utf8_decode(htmlspecialchars($msg)) . '' + . '' . nox_esc($msg) . '' . ''; } @@ -210,8 +210,8 @@ function getPreviousItem($urlPath) global $host1, $host2; return '' . 'Previous' - . '' . $host1 . utf8_decode(htmlspecialchars($urlPath)) . '' - . '' . $host1 . utf8_decode(htmlspecialchars($urlPath)) . '' + . '' . $host1 . nox_esc($urlPath) . '' + . '' . $host1 . nox_esc($urlPath) . '' . ''; } @@ -224,6 +224,11 @@ function addPreviousItem(&$listItems, $urlPath) $listItems[] = getPreviousItem($parentDir); } +function nox_esc($string) +{ + return utf8_decode(htmlspecialchars($string)); +} + function sendMessage($msg) { sendListItems(array(getMessageItem($msg))); -- 2.30.2