php.net |  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.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
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
Description:
------------
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:
---------------
1) 

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

2)

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

3)

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.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-03-21 16:09 UTC] ab@php.net
-Status: Open +Status: Not a bug
 [2017-03-21 16:09 UTC] ab@php.net
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 https://msdn.microsoft.com/en-us/library/aa365247%28VS.85%29.aspx?f=255&MSPPError=-2147217396#naming_conventions

Thanks.
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Fri Dec 04 03:01:23 2020 UTC