框架升级及修复升级后的bug

This commit is contained in:
Dev
2026-10-16 18:13:09 +08:00
parent dafb0c96c0
commit 2d342bcbd7
537 changed files with 49836 additions and 40933 deletions
+12 -4
View File
@@ -37,15 +37,16 @@ class Glob
{
/**
* Returns a regexp which is the equivalent of the glob pattern.
*
* @return string
*/
public static function toRegex(string $glob, bool $strictLeadingDot = true, bool $strictWildcardSlash = true, string $delimiter = '#')
public static function toRegex(string $glob, bool $strictLeadingDot = true, bool $strictWildcardSlash = true, string $delimiter = '#'): string
{
$firstByte = true;
$escaping = false;
$inCurlies = 0;
$regex = '';
if ($unanchored = str_starts_with($glob, '**/')) {
$glob = '/'.$glob;
}
$sizeGlob = \strlen($glob);
for ($i = 0; $i < $sizeGlob; ++$i) {
$car = $glob[$i];
@@ -76,7 +77,10 @@ class Glob
if ($delimiter === $car || '.' === $car || '(' === $car || ')' === $car || '|' === $car || '+' === $car || '^' === $car || '$' === $car) {
$regex .= "\\$car";
} elseif ('*' === $car) {
$regex .= $escaping ? '\\*' : ($strictWildcardSlash ? '[^/]*' : '.*');
if ($escaping || $strictWildcardSlash || !str_ends_with($regex, '.*')) {
// ".*.*" matches the same as ".*" but backtracks quadratically
$regex .= $escaping ? '\\*' : ($strictWildcardSlash ? '[^/]*' : '.*');
}
} elseif ('?' === $car) {
$regex .= $escaping ? '\\?' : ($strictWildcardSlash ? '[^/]' : '.');
} elseif ('{' === $car) {
@@ -106,6 +110,10 @@ class Glob
$escaping = false;
}
if ($unanchored) {
$regex = substr_replace($regex, '?', 1 + ('/' === $delimiter) + ($strictLeadingDot ? \strlen('(?=[^\.])') : 0), 0);
}
return $delimiter.'^'.$regex.'$'.$delimiter;
}
}