You are here

public function NameMungingTest::testMungeNullByte in Drupal 9

Same name and namespace in other branches
  1. 8 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 77

Class

NameMungingTest
Tests filename munging and unmunging.

Namespace

Drupal\KernelTests\Core\File

Code

public function testMungeNullByte() {
  $prefix = $this
    ->randomMachineName();
  $filename = $prefix . '.' . $this->badExtension . "\0.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.');
}