function SecurityFileUploadEventSubscriberTest::provideFilenamesNoMunge

Same name in other branches
  1. 9 core/modules/system/tests/src/Unit/Event/SecurityFileUploadEventSubscriberTest.php \Drupal\Tests\system\Unit\Event\SecurityFileUploadEventSubscriberTest::provideFilenamesNoMunge()
  2. 10 core/modules/system/tests/src/Unit/Event/SecurityFileUploadEventSubscriberTest.php \Drupal\Tests\system\Unit\Event\SecurityFileUploadEventSubscriberTest::provideFilenamesNoMunge()

Provides data for testSanitizeNameNoMunge().

Return value

array Arrays with original name and allowed extensions.

File

core/modules/system/tests/src/Unit/Event/SecurityFileUploadEventSubscriberTest.php, line 145

Class

SecurityFileUploadEventSubscriberTest
SecurityFileUploadEventSubscriber tests.

Namespace

Drupal\Tests\system\Unit\Event

Code

public static function provideFilenamesNoMunge() {
    return [
        // The following filename would be rejected by 'FileExtension' constraint
        // and therefore remains unchanged.
'.php is not munged when it would be rejected' => [
            'foo.php.php',
            'jpg',
        ],
        '.php is not munged when it would be rejected and filename contains null byte character' => [
            'foo.' . chr(0) . 'php.php',
            'jpg',
        ],
        'extension less files are not munged when they would be rejected' => [
            'foo',
            'jpg',
        ],
        'dot files are not munged when they would be rejected' => [
            '.htaccess',
            'jpg png',
        ],
    ];
}

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