コード例 #1
0
 /**
  * Tests the transliteration with max length.
  */
 public function testTransliterationWithMaxLength()
 {
     $transliteration = new PhpTransliteration();
     // Test with max length, using German. It should never split up the
     // transliteration of a single character.
     $input = 'Ä Ö Ü Å Ø äöüåøhello';
     $trunc_output = 'Ae Oe Ue A O aeoe';
     $this->assertSame($trunc_output, $transliteration->transliterate($input, 'de', '?', 17), 'Truncating to 17 characters works');
     $this->assertSame($trunc_output, $transliteration->transliterate($input, 'de', '?', 18), 'Truncating to 18 characters works');
 }
コード例 #2
0
 /**
  * Tests inclusion is safe.
  *
  * @covers ::readLanguageOverrides
  */
 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($transliterated, 'safe');
 }
コード例 #3
0
ファイル: PhpTransliteration.php プロジェクト: ddrozdik/dmaps
 /**
  * Overrides \Drupal\Component\Transliteration\PhpTransliteration::readLanguageOverrides().
  *
  * Allows modules to alter the language-specific $overrides array by invoking
  * hook_transliteration_overrides_alter().
  */
 protected function readLanguageOverrides($langcode)
 {
     parent::readLanguageOverrides($langcode);
     // Let modules alter the language-specific overrides.
     $this->moduleHandler->alter('transliteration_overrides', $this->languageOverrides[$langcode], $langcode);
 }