function FileNameMungingTest::testMungeUnsafe

Tests unsafe extensions are munged by file_munge_filename().

File

modules/simpletest/tests/file.test, line 2846

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,
    )));
}

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