question about invalid upload file names

General discussion of development ideas and the approaches taken in the 3.x branch of phpBB. The current feature release of phpBB 3 is 3.3/Proteus.
Forum rules
Please do not post support questions regarding installing, updating, or upgrading phpBB 3.3.x. If you need support for phpBB 3.3.x please visit the 3.3.x Support Forum on phpbb.com.

If you have questions regarding writing extensions please post in Extension Writers Discussion to receive proper guidance from our staff and community.
Post Reply
oferlaor
Registered User
Posts: 7
Joined: Sun Jul 14, 2024 4:39 pm

question about invalid upload file names

Post by oferlaor »

I use an iOS shortcut called "Apple frames", while it's very useful (it basically wraps screenshots with the right phone background that the screenshot was taken on), it has the peculiar behavior of changing the file name to the date. The file name is valid on iOS, but no where else (it uses the : for the time separator).

As I was trying to understand why I cant directly upload the file to phpbb, since files->common_check gives an INVALID_FILENAME error, I noticed something strange. The system actually now uses clean_filename('unique' but it still checks the common_check before that, despite it no longer being relevant as the realname later gets replaced with the hash anyway...

To test this theory I tried to see what happens if I remove this check and indeed, it all works as expected (because clean_filename('unique') runs later on anyway...

the issue is in: /phpbb/phpbb/files/upload.php

Code: Select all

/*
		// check Filename
		if (preg_match("#[\\/:*?\"<>|]#i", $file->get('realname')))
		{
			$file->error[] = $this->language->lang($this->error_prefix . 'INVALID_FILENAME', $file->get('realname'));
		}
*/

User avatar
danieltj
Infrastructure Team
Infrastructure Team
Posts: 10
Joined: Wed May 15, 2024 10:42 pm

Re: question about invalid upload file names

Post by danieltj »

If you think you've found a bug, you should add it to the tracker so it can get reviewed for a potential fix. Having said that, I've never seen a colon in a file name and didn't think it's valid. I know you can use a colon to specify a port but for files... I don't think that's allowed.

As per your code, the preg_match ((preg_match("#[\\/:*?\"<>|]#i", $file->get('realname')))) is looking for the colon and returning the error message. Perhaps the function needs tidying up a bit? Either way... raise a ticket! 🙂

oferlaor
Registered User
Posts: 7
Joined: Sun Jul 14, 2024 4:39 pm

Re: question about invalid upload file names

Post by oferlaor »

yeah, the source of the issue is that the file name was generated by an iOS shortcut.

Post Reply