diff --git a/libraries/joomla/language/language.php b/libraries/joomla/language/language.php index 1eb40fb3d64cf..9c98ad9ad6e66 100644 --- a/libraries/joomla/language/language.php +++ b/libraries/joomla/language/language.php @@ -830,7 +830,21 @@ protected function parse($filename) ini_set('track_errors', true); } - $strings = @parse_ini_file($filename); + if (!function_exists('parse_ini_file')) + { + $contents = file_get_contents($filename); + $contents = str_replace('_QQ_', '"\""', $contents); + $strings = @parse_ini_string($contents); + } + else + { + $strings = @parse_ini_file($filename); + } + + if (!is_array($strings)) + { + $strings = array(); + } // Restore error tracking to what it was before. if ($this->debug) @@ -840,7 +854,7 @@ protected function parse($filename) $this->debugFile($filename); } - return is_array($strings) ? $strings : array(); + return $strings; } /** diff --git a/tests/unit/suites/libraries/joomla/language/JLanguageTest.php b/tests/unit/suites/libraries/joomla/language/JLanguageTest.php index 61f5009326318..5132e6bd6b605 100644 --- a/tests/unit/suites/libraries/joomla/language/JLanguageTest.php +++ b/tests/unit/suites/libraries/joomla/language/JLanguageTest.php @@ -739,22 +739,22 @@ public function testSetSearchDisplayedCharactersNumberCallback() public function testExists() { $this->assertFalse( - JLanguage::exists(null) + JLanguageHelper::exists(null) ); $basePath = __DIR__ . '/data'; $this->assertTrue( - JLanguage::exists('en-GB', $basePath) + JLanguageHelper::exists('en-GB', $basePath) ); $this->assertFalse( - JLanguage::exists('es-ES', $basePath) + JLanguageHelper::exists('es-ES', $basePath) ); } /** - * Test... + * Test parsing of language ini files * * @return void */ @@ -774,7 +774,11 @@ public function testParse() 'Line: ' . __LINE__ . ' test that the strings were parsed correctly.' ); - $strings = $this->inspector->parse(__DIR__ . '/data/bad.ini'); + /** + * suppressor used as we know this will generate a warning message + * syntax error, unexpected BOOL_TRUE in + */ + $strings = @$this->inspector->parse(__DIR__ . '/data/bad.ini'); $this->assertEquals( $strings,