From f00e1f53339660fd57944f4cefdc18cf53c544b0 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak <alec@alec.pl> Date: Tue, 25 Aug 2015 05:16:39 -0400 Subject: [PATCH] CS fixes --- program/lib/Roundcube/rcube_utils.php | 21 +++++++++++---------- 1 files changed, 11 insertions(+), 10 deletions(-) diff --git a/program/lib/Roundcube/rcube_utils.php b/program/lib/Roundcube/rcube_utils.php index 924b0d6..842f677 100644 --- a/program/lib/Roundcube/rcube_utils.php +++ b/program/lib/Roundcube/rcube_utils.php @@ -153,8 +153,9 @@ */ public static function check_referer() { - $uri = parse_url($_SERVER['REQUEST_URI']); + $uri = parse_url($_SERVER['REQUEST_URI']); $referer = parse_url(self::request_header('Referer')); + return $referer['host'] == self::request_header('Host') && $referer['path'] == $uri['path']; } @@ -163,7 +164,7 @@ * * @param string Input string * @param string Encoding type: text|html|xml|js|url - * @param string Replace mode for tags: show|replace|remove + * @param string Replace mode for tags: show|remove|strict * @param boolean Convert newlines * * @return string The quoted string @@ -171,8 +172,8 @@ public static function rep_specialchars_output($str, $enctype = '', $mode = '', $newlines = true) { static $html_encode_arr = false; - static $js_rep_table = false; - static $xml_rep_table = false; + static $js_rep_table = false; + static $xml_rep_table = false; if (!is_string($str)) { $str = strval($str); @@ -187,8 +188,11 @@ $encode_arr = $html_encode_arr; - // don't replace quotes and html tags - if ($mode == 'show' || $mode == '') { + if ($mode == 'remove') { + $str = strip_tags($str); + } + else if ($mode != 'strict') { + // don't replace quotes and html tags $ltpos = strpos($str, '<'); if ($ltpos !== false && strpos($str, '>', $ltpos) !== false) { unset($encode_arr['"']); @@ -196,9 +200,6 @@ unset($encode_arr['>']); unset($encode_arr['&']); } - } - else if ($mode == 'remove') { - $str = strip_tags($str); } $out = strtr($str, $encode_arr); @@ -232,7 +233,7 @@ // encode for plaintext if ($enctype == 'text') { - return str_replace("\r\n", "\n", $mode=='remove' ? strip_tags($str) : $str); + return str_replace("\r\n", "\n", $mode == 'remove' ? strip_tags($str) : $str); } if ($enctype == 'url') { -- Gitblit v1.9.1