function NameMungingTest::testMungeNullByte

Same name in other branches
  1. 8.9.x core/tests/Drupal/KernelTests/Core/File/NameMungingTest.php \Drupal\KernelTests\Core\File\NameMungingTest::testMungeNullByte()

Tests munging with a null byte in the filename.

File

core/tests/Drupal/KernelTests/Core/File/NameMungingTest.php, line 80

Class

NameMungingTest
Tests filename munging and unmunging.

Namespace

Drupal\KernelTests\Core\File

Code

public function testMungeNullByte() {
    $prefix = $this->randomMachineName();
    $filename = $prefix . '.' . $this->badExtension . "\x00.txt";
    $this->assertEquals($prefix . '.' . $this->badExtension . '_.txt', file_munge_filename($filename, ''), 'A filename with a null byte is correctly munged to remove the null byte.');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.