1 file.test public FileNameMungingTest::testMungeUnsafe()

Tests unsafe extensions are munged by file_munge_filename().

File

core/modules/simpletest/tests/file.test, line 2736
This provides SimpleTests for the core file handling functionality. These include FileValidateTest and FileSaveTest.

Class

FileNameMungingTest
Tests for file_munge_filename() and file_unmunge_filename().

Code

public function testMungeUnsafe() {
  $prefix = $this->randomName();
  $name = "$prefix.php.txt";
  // Put the php extension in the allowed list, but since it is in the unsafe
  // extension list, it should still be munged.
  $munged_name = file_munge_filename($name, 'php txt');
  $this->assertIdentical($munged_name, "$prefix.php_.txt", format_string('The filename (%munged) has been modified from the original (%original) if the allowed extension is also on the unsafe list.', array('%munged' => $munged_name, '%original' => $name)));
}