function PhpTransliterationTest::testSafeInclude
Tests inclusion is safe.
@legacy-covers ::readLanguageOverrides
File
- 
              core/tests/ Drupal/ Tests/ Component/ Transliteration/ PhpTransliterationTest.php, line 227 
Class
- PhpTransliterationTest
- Tests Transliteration component functionality.
Namespace
Drupal\Tests\Component\TransliterationCode
public function testSafeInclude() : void {
  // 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.
