|  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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: pavel dot hlousek at gmail dot com
New email:
PHP Version: OS:


 [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 13:01:25 2021 UTC