From bb44b41af0869a29080b9cdd8e03afbb8bc9bcaa Mon Sep 17 00:00:00 2001 From: NewEraCracker Date: Sun, 19 Jun 2016 18:40:20 +0100 Subject: Fix Bug #6394 - Incorrect Output of Translation Apparently gettext() does not behave correctly when passed an empty string, this commit ensures gettext() is called only with non-empty strings (cherry picked from commit 6ae99aba5cab12440d88dd9ddaa6535c3b9b5d82) --- src/usr/local/www/classes/Form/Checkbox.class.php | 2 +- src/usr/local/www/classes/Form/Group.class.php | 2 +- src/usr/local/www/classes/Form/Input.class.php | 2 +- src/usr/local/www/classes/Form/Section.class.php | 7 ++++++- 4 files changed, 9 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/usr/local/www/classes/Form/Checkbox.class.php b/src/usr/local/www/classes/Form/Checkbox.class.php index 0601779..af258a4 100644 --- a/src/usr/local/www/classes/Form/Checkbox.class.php +++ b/src/usr/local/www/classes/Form/Checkbox.class.php @@ -63,7 +63,7 @@ class Form_Checkbox extends Form_Input { $input = parent::_getInput(); - if (!isset($this->_description)) + if (empty($this->_description)) return $input; return ''; diff --git a/src/usr/local/www/classes/Form/Group.class.php b/src/usr/local/www/classes/Form/Group.class.php index ce11969..d07010a 100644 --- a/src/usr/local/www/classes/Form/Group.class.php +++ b/src/usr/local/www/classes/Form/Group.class.php @@ -86,7 +86,7 @@ class Form_Group extends Form_Element protected function _getHelp() { - if (!isset($this->_help)) + if (empty($this->_help)) return null; $group = new Form_Element; diff --git a/src/usr/local/www/classes/Form/Input.class.php b/src/usr/local/www/classes/Form/Input.class.php index 4cdfb28..f146e1b 100644 --- a/src/usr/local/www/classes/Form/Input.class.php +++ b/src/usr/local/www/classes/Form/Input.class.php @@ -243,7 +243,7 @@ class Form_Input extends Form_Element if (!isset($this->_help) && '
' == $column) return (string)$input; - if (isset($this->_help)) + if (!empty($this->_help)) { /* Strings longer than this will break gettext. */ if (strlen($this->_help) < 7620) { diff --git a/src/usr/local/www/classes/Form/Section.class.php b/src/usr/local/www/classes/Form/Section.class.php index 631562c..f1c00c9 100644 --- a/src/usr/local/www/classes/Form/Section.class.php +++ b/src/usr/local/www/classes/Form/Section.class.php @@ -92,7 +92,12 @@ class Form_Section extends Form_Element public function __toString() { $element = parent::__toString(); - $title = htmlspecialchars(gettext($this->_title)); + + if (!empty(trim($this->_title)) || is_numeric($this->_title)) + $title = htmlspecialchars(gettext($this->_title)); + else + $title = ''; + $body = implode('', $this->_groups); $hdricon = ""; $bodyclass = '
'; -- cgit v1.1