php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #78600 PHP fails to create a file if its name ends with a dot
Submitted: 2019-09-27 00:49 UTC Modified: 2019-09-27 00:51 UTC
From: marcelotpcruz at gmail dot com Assigned:
Status: Not a bug Package: Filesystem function related
PHP Version: 7.3.10 OS: Windows 7/10
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: marcelotpcruz at gmail dot com
New email:
PHP Version: OS:

 

 [2019-09-27 00:49 UTC] marcelotpcruz at gmail dot com
Description:
------------
If I create a file manually, named as 'v.', php can read and write it, but can't create or delete.

I'm using php -a(Interactive shell).

I tested on my server with windows 7 as well with the same results.

I also tested on cmd with admin rights as well as nt authority\system(checked with whoami).

Test script:
---------------
php -a
fopen('v.', 'c+');//Does not work
file_put_contents('v.', 'dsdsd');//Does not work
fopen('v.v', 'c+');//works

//Manually  create a file .v with ddswd as content
echo file_get_contents('v.');//returns ddswd
file_put_contents('v.', 'kkk');//works
echo file_get_contents('v.');//returns kkk
unlink('v.');//Permission denied in php shell code on line 1
unlink('v.v');//works

//Delete the file manually than touch
touch('v.');//touch(): Unable to create file v. because Permission denied in php shell code on line 1

touch('v');//works


Expected result:
----------------
File is created successfully, since I can create it from prompt and notepad++ without error.

Actual result:
--------------
PHP Warning:  fopen(v.): failed to open stream: Permission denied in php shell code on line 1

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-09-27 00:51 UTC] requinix@php.net
-Status: Open +Status: Not a bug
 [2019-09-27 00:51 UTC] requinix@php.net
https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file
> Do not end a file or directory name with a space or a period. Although the underlying file system may support such
> names, the Windows shell and user interface does not. However, it is acceptable to specify a period as the first
> character of a name. For example, ".temp".
 [2019-09-27 02:09 UTC] marcelotpcruz at gmail dot com
Currently, I missread the prompt behaviour, it discreetly removes the ending dot and creates the file without it.

Thanks for your fast answer!
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Nov 10 15:01:28 2024 UTC