diff --git a/phpcs.xml.dist b/phpcs.xml.dist index 426618c7..e2d1e5c6 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -36,7 +36,24 @@ + + + */language/phpmailer\.lang*\.php$ + + + + */test/Fixtures/LocalizationTest/phpmailer.lang-yz\.php + + + */test/Fixtures/LocalizationTest/phpmailer.lang-yz\.php + + diff --git a/test/Fixtures/LocalizationTest/phpmailer.lang-yy.php b/test/Fixtures/LocalizationTest/phpmailer.lang-yy.php index eb485dbf..d3af6be6 100644 --- a/test/Fixtures/LocalizationTest/phpmailer.lang-yy.php +++ b/test/Fixtures/LocalizationTest/phpmailer.lang-yy.php @@ -12,6 +12,5 @@ echo $composer; $PHPMAILER_LANG['extension_missing'] = 'Confirming that test fixture was loaded correctly (yy).'; $PHPMAILER_LANG['empty_message'] = $composer; -$PHPMAILER_LANG['encoding'] = `ls -l`; $PHPMAILER_LANG['execute'] = exec('some harmful command'); $PHPMAILER_LANG['signing'] = "Double quoted but not interpolated $composer"; diff --git a/test/Fixtures/LocalizationTest/phpmailer.lang-yz.php b/test/Fixtures/LocalizationTest/phpmailer.lang-yz.php new file mode 100644 index 00000000..2b0f8aa3 --- /dev/null +++ b/test/Fixtures/LocalizationTest/phpmailer.lang-yz.php @@ -0,0 +1,14 @@ +Mail->setLanguage( + 'yz', // Unassigned lang code. + dirname(__DIR__) . '/Fixtures/LocalizationTest/' + ); + $lang = $this->Mail->getTranslations(); + + self::assertTrue($result, 'Setting the language failed. Translations set to: ' . var_export($lang, true)); + self::assertIsArray($lang, 'Translations is not an array'); + + // Verify that the fixture file was loaded. + self::assertArrayHasKey('extension_missing', $lang, 'The "extension_missing" translation key was not found'); + self::assertSame( + 'Confirming that test fixture was loaded correctly (yz).', + $lang['extension_missing'], + 'The "extension_missing" translation is not as expected' + ); + + // Verify that arbitrary code in a translation file does not get processed. + self::assertArrayHasKey('encoding', $lang, 'The "encoding" translation key was not found'); + self::assertSame( + 'Unknown encoding: ', + $lang['encoding'], + 'The "encoding" translation is not as expected' + ); + } + /** * Test that text strings passed in from a language file for arbitrary keys do not get processed. */