Bug #77523 [Opn]: glob pattern is limited to 260 characters

From: Date: Sat, 26 Jan 2019 00:03:23 +0000
Subject: Bug #77523 [Opn]: glob pattern is limited to 260 characters
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-219219@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=77523&edit=1 ID: 77523 Updated by: requinix@php.net Reported by: nospam at unclassified dot de Summary: glob pattern is limited to 260 characters Status: Open Type: Bug Package: *Directory/Filesystem functions Operating System: Windows 10.1709 PHP Version: 7.1.26 Block user comment: N Private report: N New Comment: 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 windows.php.net or somewhere else? Previous Comments: ------------------------------------------------------------------------ [2019-01-25 23:24:17] nospam at unclassified dot de Description: ------------ This is what I do: glob("pages/[Cc][Oo][Nn][Tt][Aa][Cc][Tt]/[Oo][Dd][Ll][Rr]0[Vv][Ss]8[Cc][Gg][Rr][Jj][Bb][Ii][Ll][Aa][Ww][Gg][Pp][Nn][Bb][Tt][Rr]4[Uu][Dd]3[Bb][Nn][Kk][Aa][Ee]/[Dd][Ee][Mm][Oo]/[Ii][Mm][Gg]/[Vv][Ss]2018[Jj][Aa][Vv][Aa][Ss][Cc][Rr][Ii][Pp][Tt][Ww][Aa][Rr][Nn][Ii][Nn][Gg][Ss].[Pp][Nn][Gg]") 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. ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=77523&edit=1

« previous php.bugs (#219219) next »