You are here

public function NameMungingTest::testMungeIgnoreInsecure 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::testMungeIgnoreInsecure()

If the system.file.allow_insecure_uploads setting evaluates to true, the file should come out untouched, no matter how evil the filename.

File

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

Class

NameMungingTest
Tests filename munging and unmunging.

Namespace

Drupal\KernelTests\Core\File

Code

public function testMungeIgnoreInsecure() {
  $this
    ->config('system.file')
    ->set('allow_insecure_uploads', 1)
    ->save();
  $munged_name = file_munge_filename($this->name, '');
  $this
    ->assertSame($munged_name, $this->name, new FormattableMarkup('The original filename (%original) matches the munged filename (%munged) when insecure uploads are enabled.', [
    '%munged' => $munged_name,
    '%original' => $this->name,
  ]));
}