? " : | \ / * are not allowed. * % causes problems with VFS UI * * @param String $filename * @dataProvider filenameProvider */ public function testVfsFilename($filename, $replacements) { $cleaned = VfsTestMail::clean_subject_for_filename($filename); $this->assertStringNotContainsString('<', $cleaned); $this->assertStringNotContainsString('>', $cleaned); $this->assertStringNotContainsString('"', $cleaned); $this->assertStringNotContainsString('#', $cleaned); $this->assertStringNotContainsString(':', $cleaned); $this->assertStringNotContainsString('|', $cleaned); $this->assertStringNotContainsString('\\', $cleaned); $this->assertStringNotContainsString('*', $cleaned); $this->assertStringNotContainsString('/', $cleaned); $this->assertStringNotContainsString('?', $cleaned); $this->assertStringNotContainsString('\x0b', $cleaned); $this->assertStringNotContainsString('😂', $cleaned); // Check if the filename is not empty $this->assertGreaterThan(0, strlen($cleaned), 'File name is empty'); if (!$replacements) { $this->assertEquals($filename, $cleaned); } else { $this->assertNotEquals($filename, $cleaned); } } public function filenameProvider() { return array( array('Normal! All allowed (!@$^&) {\'} []', false), array('Contains a >', true), array('Contains a <', true), array('Contains a "', true), array('Contains a #', true), array('Contains a :', true), array('Contains a |', true), array('Contains a \\', true), array('Contains a *', true), array('Contains a /', true), array('Contains a ?', true), array('Contains a %', true), array('Contains a \x0b', true), array('Contains a 😂', true), array('This one contains them all < > " : | \ * / ? % 😂 are not allowed', true) ); } } class VfsTestMail extends \mail_bo { // Expose for testing public static function clean_subject_for_filename($filename) { return parent::clean_subject_for_filename($filename); } }