|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #77523 extend glob pattern limit of 2048 characters
Submitted: 2019-01-25 23:24 UTC Modified: 2021-08-04 16:34 UTC
Avg. Score:3.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: nospam at unclassified dot de Assigned: cmb (profile)
Status: Wont fix Package: *Directory/Filesystem functions
PHP Version: 7.1.26 OS: Windows 10.1709
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: nospam at unclassified dot de
New email:
PHP Version: OS:


 [2019-01-25 23:24 UTC] nospam at unclassified dot de
This is what I do:


This is what I get:

Warning: glob(): Pattern exceeds the maximum allowed length of 260 characters

The string passed to glob() is 279 characters long. And it may even be longer. I has to be this complicated to determine the correct casing of a file name on disk.

This restriction is neither documented nor understandable. The pattern length should not matter at all. And even if you think that file paths of actual files in the filesystem are limited to 260 characters on Windows, you may need to update your knowledge from at least 20 years ago. This restriction only exists for deprecated legacy software, which I hope PHP is not.

Test script:
See above.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2019-01-26 00:03 UTC]
If you're on Windows then case doesn't matter, and even if it did this feels like an abuse of glob(). Tokenizing by slash and recursively scandir()ing makes more sense to me.

It's true that PHP's glob() limits the pattern to MAXPATHLEN characters when this doesn't quite make sense - with features like [] and {} the pattern can certainly be longer than the filenames it would match. So perhaps that check should be dropped.

Regardless, on my Win 10 PHP 7.1 the (PHP_)MAXPATHLEN is 2048 and your code runs fine. What SAPI (eg, php-fpm, cli) are you running this from, and did you get PHP from or somewhere else?
 [2019-01-26 09:30 UTC] nospam at unclassified dot de
I need a safe and reliable way to determine the true casing of a file name. On Linux it's easy, spell it as it is or you won't find it. Windows is more tolerant, accepting anything you throw at it. But that also means that my pages are accessible through a number of different URLs. I need my pages to be accessible on exactly one URL, so I'm correcting the spelling to the true file name. On Linux, this also allows me to accept different casing but redirect the user to the correct name.

I'm running XAMPP with Apache and PHP on Windows. It uses mod_php. I haven't tested this on Linux yet, that would be an Ubuntu 16.04 system with its default PHP packages and FastCGI.
 [2019-06-14 08:41 UTC]
-Summary: glob pattern is limited to 260 characters +Summary: extend glob pattern limit of 260 characters -Type: Bug +Type: Feature/Change Request
 [2019-06-14 09:11 UTC]
-Summary: extend glob pattern limit of 260 characters +Summary: extend glob pattern limit of 2048 characters
 [2019-06-14 09:11 UTC]
Like @requinix already stated, the maximum allowed pattern length
is 2048 as of PHP 7.1.  I do not see the need to extend this.
 [2021-08-04 16:34 UTC]
-Status: Open +Status: Wont fix -Assigned To: +Assigned To: cmb
 [2021-08-04 16:34 UTC]
> I do not see the need to extend this.

I still don't see that.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Feb 21 15:01:26 2024 UTC