|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #74283 Cannot write nor copy to file names ending with dot.
Submitted: 2017-03-21 12:24 UTC Modified: 2017-03-21 16:09 UTC
From: pavel dot hlousek at gmail dot com Assigned:
Status: Not a bug Package: Filesystem function related
PHP Version: 7.1.3 OS: Windows
Private report: No CVE-ID: None
 [2017-03-21 12:24 UTC] pavel dot hlousek at gmail dot com
PHP5.6 handled the same way file names without extension written either "filename" or "filename." (with dot character at the end of the file name).

PHP7.1.3 handles both forms of file name only in some of the functions but throws warning "Permission denied" in others.

OK functions: file_get_contents, file_exists

Bad functions: file_put_contents, copy, rename

Test script:

file_put_contents('test.', 'test.');


file_put_contents('test.txt', 'test.txt');
copy('test.txt', 'test.');


file_put_contents('test.txt', 'test.txt');
rename('test.txt', 'test.');

Expected result:
1) File "test" written to file system with "test." content.

2) File "test" exists in file system with "test.txt" content.

3) File "test" exists in file system with "test.txt" content.

Actual result:
1-3) Warning: Permission denied.

Files not created.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2017-03-21 16:09 UTC]
-Status: Open +Status: Not a bug
 [2017-03-21 16:09 UTC]
Thanks for the report. The behavior change is intentional. Paths with trailing dots are invalid on Windows. Why it happens in 7.1 is, that we are now occasionally forced to use the long path prefix and thus have to be more strict with the path normalization. Otherwise, if "test" exists, accessing "test." is tolerated. Further reading is also here

PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sat Jul 31 11:01:23 2021 UTC