You are here

public function SecurityFileUploadEventSubscriberTest::provideFilenamesNoMunge in Drupal 9

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 139

Class

SecurityFileUploadEventSubscriberTest
SecurityFileUploadEventSubscriber tests.

Namespace

Drupal\Tests\system\Unit\Event

Code

public function provideFilenamesNoMunge() {
  return [
    // The following filename would be rejected by file_validate_extension()
    // 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',
    ],
  ];
}