function PhpTransliterationTest::testSafeInclude
Same name in other branches
- 8.9.x core/tests/Drupal/Tests/Component/Transliteration/PhpTransliterationTest.php \Drupal\Tests\Component\Transliteration\PhpTransliterationTest::testSafeInclude()
- 10 core/tests/Drupal/Tests/Component/Transliteration/PhpTransliterationTest.php \Drupal\Tests\Component\Transliteration\PhpTransliterationTest::testSafeInclude()
- 11.x core/tests/Drupal/Tests/Component/Transliteration/PhpTransliterationTest.php \Drupal\Tests\Component\Transliteration\PhpTransliterationTest::testSafeInclude()
Tests inclusion is safe.
@covers ::readLanguageOverrides
File
-
core/
tests/ Drupal/ Tests/ Component/ Transliteration/ PhpTransliterationTest.php, line 226
Class
- PhpTransliterationTest
- Tests Transliteration component functionality.
Namespace
Drupal\Tests\Component\TransliterationCode
public function testSafeInclude() {
// The overrides in the transliteration data directory transliterates 0x82
// into "safe" but the overrides one directory higher transliterates the
// same character into "security hole". So by using "../index" as the
// language code we can test the ../ is stripped from the langcode.
vfsStream::setup('transliteration', NULL, [
'index.php' => '<?php $overrides = ["../index" => [0x82 => "security hole"]];',
'dir' => [
'index.php' => '<?php $overrides = ["../index" => [0x82 => "safe"]];',
],
]);
$transliteration = new PhpTransliteration(vfsStream::url('transliteration/dir'));
$transliterated = $transliteration->transliterate(chr(0xc2) . chr(0x82), '../index');
$this->assertSame('safe', $transliterated);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.