From 4b5f3f9a121dd2b606d8f455f182db21512244fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Tue, 17 Jan 2017 13:32:35 +0100 Subject: [PATCH] Merge changes from php-gettext 1.0.12 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This ensures that parameter to select_string is numeric, avoiding code injection through it. Our code is not vulnerable as we do not pass user supplied values to this function, this fix is included only to be closer to upstream. Signed-off-by: Michal Čihař --- libraries/php-gettext/gettext.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libraries/php-gettext/gettext.php b/libraries/php-gettext/gettext.php index 5064047cbd..171d14e23d 100644 --- a/libraries/php-gettext/gettext.php +++ b/libraries/php-gettext/gettext.php @@ -350,6 +350,10 @@ class gettext_reader { * @return int array index of the right plural form */ function select_string($n) { + if (!is_int($n)) { + throw new InvalidArgumentException( + "Select_string only accepts integers: " . $n); + } $string = $this->get_plural_forms(); $string = str_replace('nplurals',"\$total",$string); $string = str_replace("n",$n,$string);