From 4f9256817132280ec3940e4397302b399942320c Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Thu, 3 Mar 2022 13:16:48 -0700 Subject: [PATCH 01/11] Added system config option `legacy_url_root_behavior` --- CHANGELOG.md | 1 + system/config/system.yaml | 1 + system/src/Grav/Common/Utils.php | 13 +++++++------ 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 79c680ef7..5f5ccf218 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ * Added support to get image size for SVG vector images [#3533](https://github.com/getgrav/grav/pull/3533) * Added XSS check for uploaded SVG files before they get stored * Fixed phpstan issues (All level 2, Framework level 5) + * Added a `system.legacy_url_root_behavior` config option to enable legacy/broken `Utils::url()` behavior 2. [](#bugfix) * Fixed `'mbstring' extension is not loaded` error, use Polyfill instead [#3504](https://github.com/getgrav/grav/pull/3504) * Fixed new `Utils::pathinfo()` and `Utils::basename()` being too strict for legacy use [#3542](https://github.com/getgrav/grav/issues/3542) diff --git a/system/config/system.yaml b/system/config/system.yaml index 2de075b26..9fba968a9 100644 --- a/system/config/system.yaml +++ b/system/config/system.yaml @@ -15,6 +15,7 @@ http_x_forwarded: # Configuration options for the host: false port: true ip: true +legacy_url_root_behavior: false # Enable legacy root URL behavior that breaks URls with paths that match root languages: supported: [] # List of languages supported. eg: [en, fr, de] diff --git a/system/src/Grav/Common/Utils.php b/system/src/Grav/Common/Utils.php index 5ae819361..017c49822 100644 --- a/system/src/Grav/Common/Utils.php +++ b/system/src/Grav/Common/Utils.php @@ -134,14 +134,15 @@ abstract class Utils $resource = $locator->findResource($input, false); } } else { -// $root = $uri->rootUrl(); -// $pattern = '/(' . '\\' . $root . '[\s\/])/'; -// if (preg_match($pattern, $input, $matches)) { -// $input = static::replaceFirstOccurrence($matches[0], '', $input); -// } + // You can manually restore the old legacy behavior that does not produce expected results + if ($grav['config']->get('system.legacy_url_root_behavior', false)) { + $root = $uri->rootUrl(); + if (static::startsWith($input, $root)) { + $input = static::replaceFirstOccurrence($root, '', $input); + } + } $input = ltrim($input, '/'); - $resource = $input; } From 03f71fa49d981de6cd5be3a83f485a3744f69c3b Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Fri, 4 Mar 2022 15:37:03 -0700 Subject: [PATCH 02/11] rolled back but fixed the Utils::url() functionality --- CHANGELOG.md | 3 +-- system/config/system.yaml | 1 - system/src/Grav/Common/Utils.php | 10 ++++------ tests/unit/Grav/Common/UtilsTest.php | 22 ++++++++++++---------- 4 files changed, 17 insertions(+), 19 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5f5ccf218..2e7c277d5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,14 +5,13 @@ * Added support to get image size for SVG vector images [#3533](https://github.com/getgrav/grav/pull/3533) * Added XSS check for uploaded SVG files before they get stored * Fixed phpstan issues (All level 2, Framework level 5) - * Added a `system.legacy_url_root_behavior` config option to enable legacy/broken `Utils::url()` behavior 2. [](#bugfix) * Fixed `'mbstring' extension is not loaded` error, use Polyfill instead [#3504](https://github.com/getgrav/grav/pull/3504) * Fixed new `Utils::pathinfo()` and `Utils::basename()` being too strict for legacy use [#3542](https://github.com/getgrav/grav/issues/3542) * Fixed non-standard video html atributes generated by `{{ media.html() }}` [#3540](https://github.com/getgrav/grav/issues/3540) * Fixed entity sanitization for XSS detection * Fixed avatar save location when `account://` stream points to custom directory - * Fixed bug in `Utils::url()` when path contains root + * Fixed bug in `Utils::url()` when path contains part of root # v1.7.30 ## 02/07/2022 diff --git a/system/config/system.yaml b/system/config/system.yaml index 9fba968a9..2de075b26 100644 --- a/system/config/system.yaml +++ b/system/config/system.yaml @@ -15,7 +15,6 @@ http_x_forwarded: # Configuration options for the host: false port: true ip: true -legacy_url_root_behavior: false # Enable legacy root URL behavior that breaks URls with paths that match root languages: supported: [] # List of languages supported. eg: [en, fr, de] diff --git a/system/src/Grav/Common/Utils.php b/system/src/Grav/Common/Utils.php index 017c49822..d8db12c35 100644 --- a/system/src/Grav/Common/Utils.php +++ b/system/src/Grav/Common/Utils.php @@ -134,12 +134,10 @@ abstract class Utils $resource = $locator->findResource($input, false); } } else { - // You can manually restore the old legacy behavior that does not produce expected results - if ($grav['config']->get('system.legacy_url_root_behavior', false)) { - $root = $uri->rootUrl(); - if (static::startsWith($input, $root)) { - $input = static::replaceFirstOccurrence($root, '', $input); - } + $root = $uri->rootUrl(); + $pattern = '/(' . '\\' . $root . '[\s\/]?)/'; + if (preg_match($pattern, $input, $matches)) { + $input = static::replaceFirstOccurrence($matches[0], '', $input); } $input = ltrim($input, '/'); diff --git a/tests/unit/Grav/Common/UtilsTest.php b/tests/unit/Grav/Common/UtilsTest.php index 5cf554adc..c010ec432 100644 --- a/tests/unit/Grav/Common/UtilsTest.php +++ b/tests/unit/Grav/Common/UtilsTest.php @@ -503,18 +503,20 @@ class UtilsTest extends \Codeception\TestCase\Test self::assertSame('http://testing.dev/subdir/random/path1/path2/foobar.jpg', Utils::url('/random/path1/path2/foobar.jpg', true)); // Absolute Paths including the grav base. - self::assertSame('/subdir/subdir', Utils::url('/subdir')); - self::assertSame('/subdir/subdir/path1', Utils::url('/subdir/path1')); - self::assertSame('/subdir/subdir/path1/path2', Utils::url('/subdir/path1/path2')); - self::assertSame('/subdir/subdir/foobar.jpg', Utils::url('/subdir/foobar.jpg')); - self::assertSame('/subdir/subdir/path1/foobar.jpg', Utils::url('/subdir/path1/foobar.jpg')); + self::assertSame('/subdir/', Utils::url('/subdir')); + self::assertSame('/subdir/', Utils::url('/subdir/')); + self::assertSame('/subdir/path1', Utils::url('/subdir/path1')); + self::assertSame('/subdir/path1/path2', Utils::url('/subdir/path1/path2')); + self::assertSame('/subdir/foobar.jpg', Utils::url('/subdir/foobar.jpg')); + self::assertSame('/subdir/path1/foobar.jpg', Utils::url('/subdir/path1/foobar.jpg')); // Absolute paths from Grav root with domain. - self::assertSame('http://testing.dev/subdir/subdir', Utils::url('/subdir', true)); - self::assertSame('http://testing.dev/subdir/subdir/path1', Utils::url('/subdir/path1', true)); - self::assertSame('http://testing.dev/subdir/subdir/path1/path2', Utils::url('/subdir/path1/path2', true)); - self::assertSame('http://testing.dev/subdir/subdir/foobar.jpg', Utils::url('/subdir/foobar.jpg', true)); - self::assertSame('http://testing.dev/subdir/subdir/path1/foobar.jpg', Utils::url('/subdir/path1/foobar.jpg', true)); + self::assertSame('http://testing.dev/subdir/', Utils::url('/subdir', true)); + self::assertSame('http://testing.dev/subdir/', Utils::url('/subdir/', true)); + self::assertSame('http://testing.dev/subdir/path1', Utils::url('/subdir/path1', true)); + self::assertSame('http://testing.dev/subdir/path1/path2', Utils::url('/subdir/path1/path2', true)); + self::assertSame('http://testing.dev/subdir/foobar.jpg', Utils::url('/subdir/foobar.jpg', true)); + self::assertSame('http://testing.dev/subdir/path1/foobar.jpg', Utils::url('/subdir/path1/foobar.jpg', true)); // Relative paths from Grav root. self::assertSame('/subdir/subdir', Utils::url('subdir')); From 0abde01442f34a1e14adb25b3ee8f8f39edd8ba9 Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Sat, 5 Mar 2022 09:22:12 -0700 Subject: [PATCH 03/11] better fix --- system/src/Grav/Common/Utils.php | 2 +- tests/unit/Grav/Common/UtilsTest.php | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/system/src/Grav/Common/Utils.php b/system/src/Grav/Common/Utils.php index d8db12c35..f444fe217 100644 --- a/system/src/Grav/Common/Utils.php +++ b/system/src/Grav/Common/Utils.php @@ -135,7 +135,7 @@ abstract class Utils } } else { $root = $uri->rootUrl(); - $pattern = '/(' . '\\' . $root . '[\s\/]?)/'; + $pattern = '/(\\' . $root . '$|\\' . $root . '\/)/'; if (preg_match($pattern, $input, $matches)) { $input = static::replaceFirstOccurrence($matches[0], '', $input); } diff --git a/tests/unit/Grav/Common/UtilsTest.php b/tests/unit/Grav/Common/UtilsTest.php index c010ec432..37e863714 100644 --- a/tests/unit/Grav/Common/UtilsTest.php +++ b/tests/unit/Grav/Common/UtilsTest.php @@ -519,7 +519,9 @@ class UtilsTest extends \Codeception\TestCase\Test self::assertSame('http://testing.dev/subdir/path1/foobar.jpg', Utils::url('/subdir/path1/foobar.jpg', true)); // Relative paths from Grav root. + self::assertSame('/subdir/sub', Utils::url('/sub')); self::assertSame('/subdir/subdir', Utils::url('subdir')); + self::assertSame('/subdir/subdir2/sub', Utils::url('/subdir2/sub')); self::assertSame('/subdir/subdir/path1', Utils::url('subdir/path1')); self::assertSame('/subdir/subdir/path1/path2', Utils::url('subdir/path1/path2')); self::assertSame('/subdir/path1', Utils::url('path1')); From e09bae918cee3109b86887c05fa52a5c6b482216 Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Sat, 5 Mar 2022 11:20:54 -0700 Subject: [PATCH 04/11] fix for empty $root --- system/src/Grav/Common/Utils.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/src/Grav/Common/Utils.php b/system/src/Grav/Common/Utils.php index f444fe217..ea4d971f3 100644 --- a/system/src/Grav/Common/Utils.php +++ b/system/src/Grav/Common/Utils.php @@ -136,7 +136,7 @@ abstract class Utils } else { $root = $uri->rootUrl(); $pattern = '/(\\' . $root . '$|\\' . $root . '\/)/'; - if (preg_match($pattern, $input, $matches)) { + if (!empty($root) && preg_match($pattern, $input, $matches)) { $input = static::replaceFirstOccurrence($matches[0], '', $input); } From 9fd580c49bca326dcc78aa7a97599b0f826d7297 Mon Sep 17 00:00:00 2001 From: Andy Miller <1084697+rhukster@users.noreply.github.com> Date: Tue, 8 Mar 2022 09:45:41 -0700 Subject: [PATCH 05/11] Alternative Multiavatar Approach (#3551) * Support multiavatar by default * Support custom hash string --- composer.json | 3 +- composer.lock | 49 ++++++++++++++++++- system/blueprints/config/system.yaml | 10 ++++ system/blueprints/user/account.yaml | 7 +++ system/config/system.yaml | 1 + .../src/Grav/Common/User/Traits/UserTrait.php | 39 ++++++++++++++- 6 files changed, 105 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index db5449738..5855970e5 100644 --- a/composer.json +++ b/composer.json @@ -59,7 +59,8 @@ "itsgoingd/clockwork": "^5.0", "symfony/http-client": "^4.4", "composer/semver": "^1.4", - "rhukster/dom-sanitizer": "^1.0" + "rhukster/dom-sanitizer": "^1.0", + "multiavatar/multiavatar-php": "^1.0" }, "require-dev": { "codeception/codeception": "^4.1", diff --git a/composer.lock b/composer.lock index 965a63c1f..ff1d930a4 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "1067938388862c52927c6450e8a36df0", + "content-hash": "f0530b0fd3e574fef0852376653da5a0", "packages": [ { "name": "composer/ca-bundle", @@ -1314,6 +1314,53 @@ ], "time": "2021-05-28T08:32:12+00:00" }, + { + "name": "multiavatar/multiavatar-php", + "version": "v1.0.5", + "source": { + "type": "git", + "url": "https://github.com/multiavatar/multiavatar-php.git", + "reference": "13a62a656b1c2ca1c62dee57b4c1d8a3b04e6574" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/multiavatar/multiavatar-php/zipball/13a62a656b1c2ca1c62dee57b4c1d8a3b04e6574", + "reference": "13a62a656b1c2ca1c62dee57b4c1d8a3b04e6574", + "shasum": "" + }, + "type": "library", + "autoload": { + "classmap": [ + "Multiavatar.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "proprietary" + ], + "authors": [ + { + "name": "Gie Katon", + "homepage": "https://giekaton.com" + } + ], + "description": "Multicultural Avatar Generator", + "homepage": "https://multiavatar.com", + "keywords": [ + "avatar", + "creator", + "generator", + "image", + "maker", + "picture", + "profile" + ], + "support": { + "issues": "https://github.com/multiavatar/multiavatar-php/issues", + "source": "https://github.com/multiavatar/multiavatar-php/tree/v1.0.5" + }, + "time": "2021-03-02T07:33:46+00:00" + }, { "name": "nyholm/psr7", "version": "1.5.0", diff --git a/system/blueprints/config/system.yaml b/system/blueprints/config/system.yaml index b6beb41b9..1be73e243 100644 --- a/system/blueprints/config/system.yaml +++ b/system/blueprints/config/system.yaml @@ -1833,3 +1833,13 @@ form: options: file: PLUGIN_ADMIN.FILE folder: PLUGIN_ADMIN.FOLDER + + accounts.avatar: + type: select + label: PLUGIN_ADMIN.AVATAR + default: multiavatar + help: PLUGIN_ADMIN.AVATAR_HELP + options: + multiavatar: Multiavatar [local] + gravatar: Gravatar [external] + diff --git a/system/blueprints/user/account.yaml b/system/blueprints/user/account.yaml index 391c7370a..d8a2930c4 100644 --- a/system/blueprints/user/account.yaml +++ b/system/blueprints/user/account.yaml @@ -15,6 +15,13 @@ form: multiple: false random_name: true + avatar_hash: + type: text + label: '' + placeholder: 'e.g. dceaadcfda491f4e45' + description: PLUGIN_ADMIN.AVATAR_HASH + size: large + content: type: section title: PLUGIN_ADMIN.ACCOUNT diff --git a/system/config/system.yaml b/system/config/system.yaml index 2de075b26..33222860b 100644 --- a/system/config/system.yaml +++ b/system/config/system.yaml @@ -208,6 +208,7 @@ http: accounts: type: regular # EXPERIMENTAL: Account type: regular or flex storage: file # EXPERIMENTAL: Flex storage type: file or folder + avatar: muiltiavatar # Avatar generator [multiavatar|gravatar] flex: cache: diff --git a/system/src/Grav/Common/User/Traits/UserTrait.php b/system/src/Grav/Common/User/Traits/UserTrait.php index 0608caf5e..8f97b5032 100644 --- a/system/src/Grav/Common/User/Traits/UserTrait.php +++ b/system/src/Grav/Common/User/Traits/UserTrait.php @@ -9,12 +9,14 @@ namespace Grav\Common\User\Traits; +use Grav\Common\Filesystem\Folder; use Grav\Common\Grav; use Grav\Common\Page\Medium\ImageMedium; use Grav\Common\Page\Medium\Medium; use Grav\Common\Page\Medium\StaticImageMedium; use Grav\Common\User\Authentication; use Grav\Common\Utils; +use Gregwar\Image\Image; use function is_array; use function is_string; @@ -174,10 +176,43 @@ trait UserTrait } } + $avatar_url = ''; $email = $this->get('email'); + $hashcode = $this->get('avatar_hash'); + $avatar_generator = Grav::instance()['config']->get('system.accounts.avatar', 'multiavatar'); + + if ($hashcode || $email) { + $hash = $hashcode ?: md5(strtolower(trim($email))); + switch ($avatar_generator) { + case 'gravatar': + $avatar_url = 'https://www.gravatar.com/avatar/' . $hash; + break; + default: + return $this->generateMultiavatar($hash); + } + } + + return $avatar_url; + } + + protected function generateMultiavatar($hash) { + + $storage = Grav::instance()['locator']->findResource('image://multiavatar', true, true); + $avatar_file = "$storage/$hash.svg"; + $avatar_url = "/user/images/multiavatar/$hash.svg"; + + if (!file_exists($storage)) { + Folder::create($storage); + } + + if (!file_exists($avatar_file)) { + $mavatar = new \Multiavatar(); + file_put_contents($avatar_file, $mavatar->generate($hash, null, null)); + } + + + return Utils::url($avatar_url); - // By default fall back to gravatar image. - return $email ? 'https://www.gravatar.com/avatar/' . md5(strtolower(trim($email))) : ''; } abstract public function get($name, $default = null, $separator = null); From 499b25aad8d1ff5caf98cee9a333808de35a238c Mon Sep 17 00:00:00 2001 From: Matias Griese Date: Tue, 8 Mar 2022 19:07:55 +0200 Subject: [PATCH 06/11] Composer update --- composer.lock | 191 ++++++++++++++++++++++++++------------------------ 1 file changed, 98 insertions(+), 93 deletions(-) diff --git a/composer.lock b/composer.lock index ff1d930a4..d0dc8dfd3 100644 --- a/composer.lock +++ b/composer.lock @@ -2231,16 +2231,16 @@ }, { "name": "symfony/console", - "version": "v4.4.37", + "version": "v4.4.38", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "0259f01dbf9d77badddbbf4c2abb681f24c9cac6" + "reference": "5a50085bf5460f0c0d60a50b58388c1249826b8a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/0259f01dbf9d77badddbbf4c2abb681f24c9cac6", - "reference": "0259f01dbf9d77badddbbf4c2abb681f24c9cac6", + "url": "https://api.github.com/repos/symfony/console/zipball/5a50085bf5460f0c0d60a50b58388c1249826b8a", + "reference": "5a50085bf5460f0c0d60a50b58388c1249826b8a", "shasum": "" }, "require": { @@ -2301,7 +2301,7 @@ "description": "Eases the creation of beautiful and testable command line interfaces", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/console/tree/v4.4.37" + "source": "https://github.com/symfony/console/tree/v4.4.38" }, "funding": [ { @@ -2317,7 +2317,7 @@ "type": "tidelift" } ], - "time": "2022-01-26T16:15:26+00:00" + "time": "2022-01-30T21:23:57+00:00" }, { "name": "symfony/contracts", @@ -2499,16 +2499,16 @@ }, { "name": "symfony/http-client", - "version": "v4.4.37", + "version": "v4.4.39", "source": { "type": "git", "url": "https://github.com/symfony/http-client.git", - "reference": "8129ccd6233338e1d495b7734c003053766cb262" + "reference": "40342406a975385c5b21e929df46e3fc0278853d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-client/zipball/8129ccd6233338e1d495b7734c003053766cb262", - "reference": "8129ccd6233338e1d495b7734c003053766cb262", + "url": "https://api.github.com/repos/symfony/http-client/zipball/40342406a975385c5b21e929df46e3fc0278853d", + "reference": "40342406a975385c5b21e929df46e3fc0278853d", "shasum": "" }, "require": { @@ -2560,7 +2560,7 @@ "description": "Provides powerful methods to fetch HTTP resources synchronously or asynchronously", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/http-client/tree/v4.4.37" + "source": "https://github.com/symfony/http-client/tree/v4.4.39" }, "funding": [ { @@ -2576,11 +2576,11 @@ "type": "tidelift" } ], - "time": "2022-01-19T13:29:07+00:00" + "time": "2022-02-28T13:17:32+00:00" }, { "name": "symfony/polyfill-ctype", - "version": "v1.24.0", + "version": "v1.25.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-ctype.git", @@ -2612,12 +2612,12 @@ } }, "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Ctype\\": "" - }, "files": [ "bootstrap.php" - ] + ], + "psr-4": { + "Symfony\\Polyfill\\Ctype\\": "" + } }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -2642,7 +2642,7 @@ "portable" ], "support": { - "source": "https://github.com/symfony/polyfill-ctype/tree/v1.24.0" + "source": "https://github.com/symfony/polyfill-ctype/tree/v1.25.0" }, "funding": [ { @@ -2662,7 +2662,7 @@ }, { "name": "symfony/polyfill-iconv", - "version": "v1.24.0", + "version": "v1.25.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-iconv.git", @@ -2725,7 +2725,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-iconv/tree/v1.24.0" + "source": "https://github.com/symfony/polyfill-iconv/tree/v1.25.0" }, "funding": [ { @@ -2745,7 +2745,7 @@ }, { "name": "symfony/polyfill-mbstring", - "version": "v1.24.0", + "version": "v1.25.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", @@ -2808,7 +2808,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.24.0" + "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.25.0" }, "funding": [ { @@ -2828,7 +2828,7 @@ }, { "name": "symfony/polyfill-php74", - "version": "v1.24.0", + "version": "v1.25.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php74.git", @@ -2888,7 +2888,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php74/tree/v1.24.0" + "source": "https://github.com/symfony/polyfill-php74/tree/v1.25.0" }, "funding": [ { @@ -2908,16 +2908,16 @@ }, { "name": "symfony/polyfill-php80", - "version": "v1.24.0", + "version": "v1.25.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php80.git", - "reference": "57b712b08eddb97c762a8caa32c84e037892d2e9" + "reference": "4407588e0d3f1f52efb65fbe92babe41f37fe50c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/57b712b08eddb97c762a8caa32c84e037892d2e9", - "reference": "57b712b08eddb97c762a8caa32c84e037892d2e9", + "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/4407588e0d3f1f52efb65fbe92babe41f37fe50c", + "reference": "4407588e0d3f1f52efb65fbe92babe41f37fe50c", "shasum": "" }, "require": { @@ -2971,7 +2971,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php80/tree/v1.24.0" + "source": "https://github.com/symfony/polyfill-php80/tree/v1.25.0" }, "funding": [ { @@ -2987,11 +2987,11 @@ "type": "tidelift" } ], - "time": "2021-09-13T13:58:33+00:00" + "time": "2022-03-04T08:16:47+00:00" }, { "name": "symfony/polyfill-php81", - "version": "v1.24.0", + "version": "v1.25.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php81.git", @@ -3050,7 +3050,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php81/tree/v1.24.0" + "source": "https://github.com/symfony/polyfill-php81/tree/v1.25.0" }, "funding": [ { @@ -3132,16 +3132,16 @@ }, { "name": "symfony/var-dumper", - "version": "v4.4.37", + "version": "v4.4.39", "source": { "type": "git", "url": "https://github.com/symfony/var-dumper.git", - "reference": "e74eee4ec02de71db3d60151aa5b203c990556df" + "reference": "35237c5e5dcb6593a46a860ba5b29c1d4683d80e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/var-dumper/zipball/e74eee4ec02de71db3d60151aa5b203c990556df", - "reference": "e74eee4ec02de71db3d60151aa5b203c990556df", + "url": "https://api.github.com/repos/symfony/var-dumper/zipball/35237c5e5dcb6593a46a860ba5b29c1d4683d80e", + "reference": "35237c5e5dcb6593a46a860ba5b29c1d4683d80e", "shasum": "" }, "require": { @@ -3201,7 +3201,7 @@ "dump" ], "support": { - "source": "https://github.com/symfony/var-dumper/tree/v4.4.37" + "source": "https://github.com/symfony/var-dumper/tree/v4.4.39" }, "funding": [ { @@ -3217,7 +3217,7 @@ "type": "tidelift" } ], - "time": "2022-01-02T09:41:36+00:00" + "time": "2022-02-25T10:38:15+00:00" }, { "name": "symfony/yaml", @@ -3491,16 +3491,16 @@ }, { "name": "codeception/codeception", - "version": "4.1.29", + "version": "4.1.30", "source": { "type": "git", "url": "https://github.com/Codeception/Codeception.git", - "reference": "f8dec8f2bf5347cc596aaf141753f4fb2504c17c" + "reference": "a035d77d070fa57fad438e07a65447aeca248c45" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Codeception/Codeception/zipball/f8dec8f2bf5347cc596aaf141753f4fb2504c17c", - "reference": "f8dec8f2bf5347cc596aaf141753f4fb2504c17c", + "url": "https://api.github.com/repos/Codeception/Codeception/zipball/a035d77d070fa57fad438e07a65447aeca248c45", + "reference": "a035d77d070fa57fad438e07a65447aeca248c45", "shasum": "" }, "require": { @@ -3577,7 +3577,7 @@ ], "support": { "issues": "https://github.com/Codeception/Codeception/issues", - "source": "https://github.com/Codeception/Codeception/tree/4.1.29" + "source": "https://github.com/Codeception/Codeception/tree/4.1.30" }, "funding": [ { @@ -3585,7 +3585,7 @@ "type": "open_collective" } ], - "time": "2022-01-29T16:56:03+00:00" + "time": "2022-03-05T18:12:30+00:00" }, { "name": "codeception/lib-asserts", @@ -3903,29 +3903,30 @@ }, { "name": "doctrine/instantiator", - "version": "1.4.0", + "version": "1.4.1", "source": { "type": "git", "url": "https://github.com/doctrine/instantiator.git", - "reference": "d56bf6102915de5702778fe20f2de3b2fe570b5b" + "reference": "10dcfce151b967d20fde1b34ae6640712c3891bc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/instantiator/zipball/d56bf6102915de5702778fe20f2de3b2fe570b5b", - "reference": "d56bf6102915de5702778fe20f2de3b2fe570b5b", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/10dcfce151b967d20fde1b34ae6640712c3891bc", + "reference": "10dcfce151b967d20fde1b34ae6640712c3891bc", "shasum": "" }, "require": { "php": "^7.1 || ^8.0" }, "require-dev": { - "doctrine/coding-standard": "^8.0", + "doctrine/coding-standard": "^9", "ext-pdo": "*", "ext-phar": "*", - "phpbench/phpbench": "^0.13 || 1.0.0-alpha2", - "phpstan/phpstan": "^0.12", - "phpstan/phpstan-phpunit": "^0.12", - "phpunit/phpunit": "^7.0 || ^8.0 || ^9.0" + "phpbench/phpbench": "^0.16 || ^1", + "phpstan/phpstan": "^1.4", + "phpstan/phpstan-phpunit": "^1", + "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5", + "vimeo/psalm": "^4.22" }, "type": "library", "autoload": { @@ -3952,7 +3953,7 @@ ], "support": { "issues": "https://github.com/doctrine/instantiator/issues", - "source": "https://github.com/doctrine/instantiator/tree/1.4.0" + "source": "https://github.com/doctrine/instantiator/tree/1.4.1" }, "funding": [ { @@ -3968,7 +3969,7 @@ "type": "tidelift" } ], - "time": "2020-11-10T18:47:58+00:00" + "time": "2022-03-03T08:28:38+00:00" }, { "name": "getgrav/markdowndocs", @@ -4173,12 +4174,12 @@ } }, "autoload": { - "psr-4": { - "GuzzleHttp\\Promise\\": "src/" - }, "files": [ "src/functions_include.php" - ] + ], + "psr-4": { + "GuzzleHttp\\Promise\\": "src/" + } }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -4232,25 +4233,29 @@ }, { "name": "myclabs/deep-copy", - "version": "1.10.2", + "version": "1.11.0", "source": { "type": "git", "url": "https://github.com/myclabs/DeepCopy.git", - "reference": "776f831124e9c62e1a2c601ecc52e776d8bb7220" + "reference": "14daed4296fae74d9e3201d2c4925d1acb7aa614" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/776f831124e9c62e1a2c601ecc52e776d8bb7220", - "reference": "776f831124e9c62e1a2c601ecc52e776d8bb7220", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/14daed4296fae74d9e3201d2c4925d1acb7aa614", + "reference": "14daed4296fae74d9e3201d2c4925d1acb7aa614", "shasum": "" }, "require": { "php": "^7.1 || ^8.0" }, + "conflict": { + "doctrine/collections": "<1.6.8", + "doctrine/common": "<2.13.3 || >=3,<3.2.2" + }, "require-dev": { - "doctrine/collections": "^1.0", - "doctrine/common": "^2.6", - "phpunit/phpunit": "^7.1" + "doctrine/collections": "^1.6.8", + "doctrine/common": "^2.13.3 || ^3.2.2", + "phpunit/phpunit": "^7.5.20 || ^8.5.23 || ^9.5.13" }, "type": "library", "autoload": { @@ -4275,7 +4280,7 @@ ], "support": { "issues": "https://github.com/myclabs/DeepCopy/issues", - "source": "https://github.com/myclabs/DeepCopy/tree/1.10.2" + "source": "https://github.com/myclabs/DeepCopy/tree/1.11.0" }, "funding": [ { @@ -4283,7 +4288,7 @@ "type": "tidelift" } ], - "time": "2020-11-13T09:40:50+00:00" + "time": "2022-03-03T13:19:32+00:00" }, { "name": "nikic/php-parser", @@ -4681,16 +4686,16 @@ }, { "name": "phpstan/phpstan", - "version": "1.4.6", + "version": "1.4.8", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "8a7761f1c520e0dad6e04d862fdc697445457cfe" + "reference": "2a6d6704b17c4db6190cc3104056c0aad740cb15" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/8a7761f1c520e0dad6e04d862fdc697445457cfe", - "reference": "8a7761f1c520e0dad6e04d862fdc697445457cfe", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/2a6d6704b17c4db6190cc3104056c0aad740cb15", + "reference": "2a6d6704b17c4db6190cc3104056c0aad740cb15", "shasum": "" }, "require": { @@ -4721,7 +4726,7 @@ "description": "PHPStan - PHP Static Analysis Tool", "support": { "issues": "https://github.com/phpstan/phpstan/issues", - "source": "https://github.com/phpstan/phpstan/tree/1.4.6" + "source": "https://github.com/phpstan/phpstan/tree/1.4.8" }, "funding": [ { @@ -4741,7 +4746,7 @@ "type": "tidelift" } ], - "time": "2022-02-06T12:56:13+00:00" + "time": "2022-03-04T13:03:56+00:00" }, { "name": "phpstan/phpstan-deprecation-rules", @@ -4795,16 +4800,16 @@ }, { "name": "phpunit/php-code-coverage", - "version": "9.2.11", + "version": "9.2.15", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "665a1ac0a763c51afc30d6d130dac0813092b17f" + "reference": "2e9da11878c4202f97915c1cb4bb1ca318a63f5f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/665a1ac0a763c51afc30d6d130dac0813092b17f", - "reference": "665a1ac0a763c51afc30d6d130dac0813092b17f", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/2e9da11878c4202f97915c1cb4bb1ca318a63f5f", + "reference": "2e9da11878c4202f97915c1cb4bb1ca318a63f5f", "shasum": "" }, "require": { @@ -4860,7 +4865,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", - "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.11" + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.15" }, "funding": [ { @@ -4868,7 +4873,7 @@ "type": "github" } ], - "time": "2022-02-18T12:46:09+00:00" + "time": "2022-03-07T09:28:20+00:00" }, { "name": "phpunit/php-file-iterator", @@ -5113,16 +5118,16 @@ }, { "name": "phpunit/phpunit", - "version": "9.5.14", + "version": "9.5.18", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "1883687169c017d6ae37c58883ca3994cfc34189" + "reference": "1b5856028273bfd855e60a887278857d872ec67a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/1883687169c017d6ae37c58883ca3994cfc34189", - "reference": "1883687169c017d6ae37c58883ca3994cfc34189", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/1b5856028273bfd855e60a887278857d872ec67a", + "reference": "1b5856028273bfd855e60a887278857d872ec67a", "shasum": "" }, "require": { @@ -5138,7 +5143,7 @@ "phar-io/version": "^3.0.2", "php": ">=7.3", "phpspec/prophecy": "^1.12.1", - "phpunit/php-code-coverage": "^9.2.7", + "phpunit/php-code-coverage": "^9.2.13", "phpunit/php-file-iterator": "^3.0.5", "phpunit/php-invoker": "^3.1.1", "phpunit/php-text-template": "^2.0.3", @@ -5200,7 +5205,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", - "source": "https://github.com/sebastianbergmann/phpunit/tree/9.5.14" + "source": "https://github.com/sebastianbergmann/phpunit/tree/9.5.18" }, "funding": [ { @@ -5212,7 +5217,7 @@ "type": "github" } ], - "time": "2022-02-18T12:54:07+00:00" + "time": "2022-03-08T06:52:28+00:00" }, { "name": "psr/http-client", @@ -6437,16 +6442,16 @@ }, { "name": "symfony/dom-crawler", - "version": "v5.4.3", + "version": "v5.4.6", "source": { "type": "git", "url": "https://github.com/symfony/dom-crawler.git", - "reference": "2634381fdf27a2a0a8ac8eb404025eb656c65d0c" + "reference": "c0bda97480d96337bd3866026159a8b358665457" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/dom-crawler/zipball/2634381fdf27a2a0a8ac8eb404025eb656c65d0c", - "reference": "2634381fdf27a2a0a8ac8eb404025eb656c65d0c", + "url": "https://api.github.com/repos/symfony/dom-crawler/zipball/c0bda97480d96337bd3866026159a8b358665457", + "reference": "c0bda97480d96337bd3866026159a8b358665457", "shasum": "" }, "require": { @@ -6492,7 +6497,7 @@ "description": "Eases DOM navigation for HTML and XML documents", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/dom-crawler/tree/v5.4.3" + "source": "https://github.com/symfony/dom-crawler/tree/v5.4.6" }, "funding": [ { @@ -6508,7 +6513,7 @@ "type": "tidelift" } ], - "time": "2022-01-02T09:53:40+00:00" + "time": "2022-03-02T12:42:23+00:00" }, { "name": "symfony/finder", From e0deeeb551b99fa2b5f75c2f77c11672806d8944 Mon Sep 17 00:00:00 2001 From: Matias Griese Date: Tue, 8 Mar 2022 19:15:46 +0200 Subject: [PATCH 07/11] Make new avatar logic more robust --- .../src/Grav/Common/User/Traits/UserTrait.php | 47 ++++++++++++------- 1 file changed, 29 insertions(+), 18 deletions(-) diff --git a/system/src/Grav/Common/User/Traits/UserTrait.php b/system/src/Grav/Common/User/Traits/UserTrait.php index 8f97b5032..91c41aa11 100644 --- a/system/src/Grav/Common/User/Traits/UserTrait.php +++ b/system/src/Grav/Common/User/Traits/UserTrait.php @@ -16,7 +16,8 @@ use Grav\Common\Page\Medium\Medium; use Grav\Common\Page\Medium\StaticImageMedium; use Grav\Common\User\Authentication; use Grav\Common\Utils; -use Gregwar\Image\Image; +use Multiavatar; +use RocketTheme\Toolbox\ResourceLocator\UniformResourceLocator; use function is_array; use function is_string; @@ -176,40 +177,50 @@ trait UserTrait } } - $avatar_url = ''; $email = $this->get('email'); - $hashcode = $this->get('avatar_hash'); $avatar_generator = Grav::instance()['config']->get('system.accounts.avatar', 'multiavatar'); - - if ($hashcode || $email) { - $hash = $hashcode ?: md5(strtolower(trim($email))); - switch ($avatar_generator) { - case 'gravatar': - $avatar_url = 'https://www.gravatar.com/avatar/' . $hash; - break; - default: - return $this->generateMultiavatar($hash); + if ($avatar_generator === 'gravatar') { + if (!$email) { + return ''; } + + $hash = md5(strtolower(trim($email))); + + return 'https://www.gravatar.com/avatar/' . $hash; } - return $avatar_url; + $hash = $this->get('avatar_hash'); + if (!$hash) { + $username = $this->get('username'); + $hash = md5(strtolower(trim($email ?? $username))); + } + + return $this->generateMultiavatar($hash); } - protected function generateMultiavatar($hash) { + /** + * @param string $hash + * @return string + */ + protected function generateMultiavatar(string $hash): string + { + /** @var UniformResourceLocator $locator */ + $locator = Grav::instance()['locator']; - $storage = Grav::instance()['locator']->findResource('image://multiavatar', true, true); - $avatar_file = "$storage/$hash.svg"; - $avatar_url = "/user/images/multiavatar/$hash.svg"; + $storage = $locator->findResource('image://multiavatar', true, true); + $avatar_file = "{$storage}/{$hash}.svg"; if (!file_exists($storage)) { Folder::create($storage); } if (!file_exists($avatar_file)) { - $mavatar = new \Multiavatar(); + $mavatar = new Multiavatar(); + file_put_contents($avatar_file, $mavatar->generate($hash, null, null)); } + $avatar_url = $locator->findResource("image://multiavatar/{$hash}.svg", false, true); return Utils::url($avatar_url); From e60ba13d75ab194354e6cffa3f06219b1d7836cc Mon Sep 17 00:00:00 2001 From: Djamil Legato Date: Tue, 8 Mar 2022 09:32:28 -0800 Subject: [PATCH 08/11] Fixed issue with URL method not escaping subpaths slashes --- system/src/Grav/Common/Utils.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/src/Grav/Common/Utils.php b/system/src/Grav/Common/Utils.php index ea4d971f3..a0e1a5ef7 100644 --- a/system/src/Grav/Common/Utils.php +++ b/system/src/Grav/Common/Utils.php @@ -135,7 +135,7 @@ abstract class Utils } } else { $root = $uri->rootUrl(); - $pattern = '/(\\' . $root . '$|\\' . $root . '\/)/'; + $pattern = '#(' . $root . '$|' . $root . '/)#'; if (!empty($root) && preg_match($pattern, $input, $matches)) { $input = static::replaceFirstOccurrence($matches[0], '', $input); } From 41b8fbb0e09e0c2406bd43b55e03f4bba7ee4e8c Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Tue, 8 Mar 2022 10:45:44 -0700 Subject: [PATCH 09/11] Update changelog + Accounts in sidebar --- CHANGELOG.md | 23 ++++++----- system/blueprints/config/system.yaml | 58 ++++++++++++++++------------ system/config/system.yaml | 2 +- 3 files changed, 47 insertions(+), 36 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2e7c277d5..8cffdfcc2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,16 +2,19 @@ ## mm/dd/2022 1. [](#new) - * Added support to get image size for SVG vector images [#3533](https://github.com/getgrav/grav/pull/3533) - * Added XSS check for uploaded SVG files before they get stored - * Fixed phpstan issues (All level 2, Framework level 5) -2. [](#bugfix) - * Fixed `'mbstring' extension is not loaded` error, use Polyfill instead [#3504](https://github.com/getgrav/grav/pull/3504) - * Fixed new `Utils::pathinfo()` and `Utils::basename()` being too strict for legacy use [#3542](https://github.com/getgrav/grav/issues/3542) - * Fixed non-standard video html atributes generated by `{{ media.html() }}` [#3540](https://github.com/getgrav/grav/issues/3540) - * Fixed entity sanitization for XSS detection - * Fixed avatar save location when `account://` stream points to custom directory - * Fixed bug in `Utils::url()` when path contains part of root + * Added new local Multiavatar (local generation). **This will be default in Grav 1.8** + * Added support to get image size for SVG vector images [#3533](https://github.com/getgrav/grav/pull/3533) + * Added XSS check for uploaded SVG files before they get stored + * Fixed phpstan issues (All level 2, Framework level 5) +2. [](#improved) + * Moved Accounts out of Experimental section of System configuration +3. [](#bugfix) + * Fixed `'mbstring' extension is not loaded` error, use Polyfill instead [#3504](https://github.com/getgrav/grav/pull/3504) + * Fixed new `Utils::pathinfo()` and `Utils::basename()` being too strict for legacy use [#3542](https://github.com/getgrav/grav/issues/3542) + * Fixed non-standard video html atributes generated by `{{ media.html() }}` [#3540](https://github.com/getgrav/grav/issues/3540) + * Fixed entity sanitization for XSS detection + * Fixed avatar save location when `account://` stream points to custom directory + * Fixed bug in `Utils::url()` when path contains part of root # v1.7.30 ## 02/07/2022 diff --git a/system/blueprints/config/system.yaml b/system/blueprints/config/system.yaml index 1be73e243..787fcd577 100644 --- a/system/blueprints/config/system.yaml +++ b/system/blueprints/config/system.yaml @@ -1786,35 +1786,15 @@ form: validate: type: bool - experimental: + + accounts: type: tab - title: PLUGIN_ADMIN.EXPERIMENTAL + title: PLUGIN_ADMIN.ACCOUNTS fields: - experimental_section: - type: section - title: PLUGIN_ADMIN.EXPERIMENTAL - underline: true - -# flex_pages: -# type: section -# title: Flex Pages -# -# pages.type: -# type: select -# label: PLUGIN_ADMIN.PAGES_TYPE -# highlight: regular -# help: PLUGIN_ADMIN.PAGES_TYPE_HELP -# options: -# regular: PLUGIN_ADMIN.REGULAR -# flex: PLUGIN_ADMIN.FLEX - - pages.type: - type: hidden - flex_accounts: type: section - title: Flex Accounts + title: User Accounts accounts.type: type: select @@ -1837,9 +1817,37 @@ form: accounts.avatar: type: select label: PLUGIN_ADMIN.AVATAR - default: multiavatar + default: gravatar help: PLUGIN_ADMIN.AVATAR_HELP options: multiavatar: Multiavatar [local] gravatar: Gravatar [external] +# experimental: +# type: tab +# title: PLUGIN_ADMIN.EXPERIMENTAL +# +# fields: +# experimental_section: +# type: section +# title: PLUGIN_ADMIN.EXPERIMENTAL +# underline: true +# +# flex_pages: +# type: section +# title: Flex Pages +# +# pages.type: +# type: select +# label: PLUGIN_ADMIN.PAGES_TYPE +# highlight: regular +# help: PLUGIN_ADMIN.PAGES_TYPE_HELP +# options: +# regular: PLUGIN_ADMIN.REGULAR +# flex: PLUGIN_ADMIN.FLEX +# +# pages.type: +# type: hidden + + + diff --git a/system/config/system.yaml b/system/config/system.yaml index 33222860b..380d650eb 100644 --- a/system/config/system.yaml +++ b/system/config/system.yaml @@ -208,7 +208,7 @@ http: accounts: type: regular # EXPERIMENTAL: Account type: regular or flex storage: file # EXPERIMENTAL: Flex storage type: file or folder - avatar: muiltiavatar # Avatar generator [multiavatar|gravatar] + avatar: gravatar # Avatar generator [multiavatar|gravatar] flex: cache: From c7bc5f5b59b1f8a3d1967ea00d7c677338440aa3 Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Tue, 8 Mar 2022 14:00:06 -0700 Subject: [PATCH 10/11] hash for multiavatar only --- system/blueprints/user/account.yaml | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/system/blueprints/user/account.yaml b/system/blueprints/user/account.yaml index d8a2930c4..ef5f25b04 100644 --- a/system/blueprints/user/account.yaml +++ b/system/blueprints/user/account.yaml @@ -15,12 +15,16 @@ form: multiple: false random_name: true - avatar_hash: - type: text - label: '' - placeholder: 'e.g. dceaadcfda491f4e45' - description: PLUGIN_ADMIN.AVATAR_HASH - size: large + multiavatar_only: + type: conditional + condition: config.system.accounts.avatar == 'multiavatar' + fields: + avatar_hash: + type: text + label: '' + placeholder: 'e.g. dceaadcfda491f4e45' + description: PLUGIN_ADMIN.AVATAR_HASH + size: large content: type: section From 4d4efb31e3b3a857118783e840ef82699e809ffe Mon Sep 17 00:00:00 2001 From: Matias Griese Date: Wed, 9 Mar 2022 12:25:46 +0200 Subject: [PATCH 11/11] Escape root url pattern in Utils::url() --- system/src/Grav/Common/Utils.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/src/Grav/Common/Utils.php b/system/src/Grav/Common/Utils.php index a0e1a5ef7..145a89356 100644 --- a/system/src/Grav/Common/Utils.php +++ b/system/src/Grav/Common/Utils.php @@ -134,7 +134,7 @@ abstract class Utils $resource = $locator->findResource($input, false); } } else { - $root = $uri->rootUrl(); + $root = preg_quote($uri->rootUrl(), '#'); $pattern = '#(' . $root . '$|' . $root . '/)#'; if (!empty($root) && preg_match($pattern, $input, $matches)) { $input = static::replaceFirstOccurrence($matches[0], '', $input);