Fixed schema loading when the file path contains at least 4 numbers in a row

this spectactularly stupid bug could also have been addressed using a [^\/] in place of the . in the pattern, but I thought it made sense to make it impossible for this to happen again by making sure the regex only sees the file name.

fixes #5129
This commit is contained in:
Dylan K. Taylor 2022-07-04 22:15:50 +01:00
parent 56cf59355f
commit 4909c0f257
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D
2 changed files with 8 additions and 6 deletions

View File

@ -259,10 +259,11 @@ final class BlockStateUpgradeSchemaUtils{
$iterator = new \RegexIterator(
new \FilesystemIterator(
$path,
\FilesystemIterator::CURRENT_AS_PATHNAME | \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::UNIX_PATHS
\FilesystemIterator::KEY_AS_FILENAME | \FilesystemIterator::SKIP_DOTS
),
'/\/(\d{4}).*\.json$/',
\RegexIterator::GET_MATCH
'/^(\d{4}).*\.json$/',
\RegexIterator::GET_MATCH,
\RegexIterator::USE_KEY
);
$result = [];

View File

@ -42,10 +42,11 @@ final class ItemIdMetaUpgradeSchemaUtils{
$iterator = new \RegexIterator(
new \FilesystemIterator(
$path,
\FilesystemIterator::CURRENT_AS_PATHNAME | \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::UNIX_PATHS
\FilesystemIterator::KEY_AS_FILENAME | \FilesystemIterator::SKIP_DOTS
),
'/\/(\d{4}).*\.json$/',
\RegexIterator::GET_MATCH
'/^(\d{4}).*\.json$/',
\RegexIterator::GET_MATCH,
\RegexIterator::USE_KEY
);
$result = [];