From aca04cee6b9153c6cdd8deeaa1ea9375637ed69b Mon Sep 17 00:00:00 2001 From: y-u-s-s-u-f-i-s-l-a-m Date: Thu, 23 May 2019 16:43:27 +0200 Subject: [PATCH 1/5] Create now.json (#2515) * Create now.json * Update now.json --- now.json | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 now.json diff --git a/now.json b/now.json new file mode 100644 index 000000000..fe7b94b37 --- /dev/null +++ b/now.json @@ -0,0 +1,4 @@ + { + "version": 2, + "builds": [{ "src": "*.php", "use": "@now/php" }] +} From 92e8dbf4ea2ece2c3c792819cb4bdc92babfbd17 Mon Sep 17 00:00:00 2001 From: Djamil Legato Date: Thu, 23 May 2019 09:44:47 -0700 Subject: [PATCH 2/5] Added Funding.yml --- .github/FUNDING.yml | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 .github/FUNDING.yml diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 000000000..e84f52bf5 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,8 @@ +# These are supported funding model platforms + +github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] +patreon: # Replace with a single Patreon username +open_collective: grav +ko_fi: # Replace with a single Ko-fi username +tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel +custom: # Replace with a single custom sponsorship URL From 8a7f624558cb3735e892cd41f77cbb5db9d57f2b Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Sun, 26 May 2019 13:23:08 +0300 Subject: [PATCH 3/5] =?UTF-8?q?return=20the=20found=20language=20rather=20?= =?UTF-8?q?than=20just=20=E2=80=98true=E2=80=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- system/src/Grav/Common/Utils.php | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/system/src/Grav/Common/Utils.php b/system/src/Grav/Common/Utils.php index 9b0992f99..32da72b81 100644 --- a/system/src/Grav/Common/Utils.php +++ b/system/src/Grav/Common/Utils.php @@ -975,20 +975,16 @@ abstract class Utils * * @param string $string The path * - * @return bool + * @return bool|string Either false or the language * */ public static function pathPrefixedByLangCode($string) { - if (strlen($string) <= 3) { - return false; - } - $languages_enabled = Grav::instance()['config']->get('system.languages.supported', []); $parts = explode('/', trim($string, '/')); if (count($parts) > 0 && in_array($parts[0], $languages_enabled)) { - return true; + return $parts[0]; } return false; From 23a928c5b7f71d8f11e93b0a7ef2344b084c44c7 Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Sun, 26 May 2019 11:37:18 +0300 Subject: [PATCH 4/5] Fixed bitwise operator in `TwigExtension::exifFunc()` #2518 --- CHANGELOG.md | 1 + system/src/Grav/Common/Twig/TwigExtension.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 43149a09b..2f87d5e64 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ * Fixed GPM errors from blueprints not being logged [#2505](https://github.com/getgrav/grav/issues/2505) * Don't error when IP is invalid [#2507](https://github.com/getgrav/grav/issues/2507) * Fixed regression with `bin/plugin` not listing the plugins available (1c725c0) + * Fixed bitwise operator in `TwigExtension::exifFunc()` [#2518](https://github.com/getgrav/grav/issues/2518) # v1.6.9 ## 05/09/2019 diff --git a/system/src/Grav/Common/Twig/TwigExtension.php b/system/src/Grav/Common/Twig/TwigExtension.php index baced9abb..7e596d98a 100644 --- a/system/src/Grav/Common/Twig/TwigExtension.php +++ b/system/src/Grav/Common/Twig/TwigExtension.php @@ -1154,7 +1154,7 @@ class TwigExtension extends \Twig_Extension implements \Twig_Extension_GlobalsIn $exif_reader = $this->grav['exif']->getReader(); - if ($image & file_exists($image) && $this->config->get('system.media.auto_metadata_exif') && $exif_reader) { + if ($image && file_exists($image) && $this->config->get('system.media.auto_metadata_exif') && $exif_reader) { $exif_data = $exif_reader->read($image); From c4c70d082cfbd2f0c19c9b173665f9eef1d830cf Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Sun, 26 May 2019 13:36:12 +0300 Subject: [PATCH 5/5] Fixes #2510 and #2511 --- CHANGELOG.md | 2 ++ system/src/Grav/Common/Service/SessionServiceProvider.php | 8 ++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2f87d5e64..877e073f3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,8 @@ * Don't error when IP is invalid [#2507](https://github.com/getgrav/grav/issues/2507) * Fixed regression with `bin/plugin` not listing the plugins available (1c725c0) * Fixed bitwise operator in `TwigExtension::exifFunc()` [#2518](https://github.com/getgrav/grav/issues/2518) + * Fixed issue with lang prefix incorrectly identifying as admin [#2511](https://github.com/getgrav/grav/issues/2511) + * Fixed issue with `U0ils::pathPrefixedBYLanguageCode()` and trailing slash [#2510](https://github.com/getgrav/grav/issues/2511) # v1.6.9 ## 05/09/2019 diff --git a/system/src/Grav/Common/Service/SessionServiceProvider.php b/system/src/Grav/Common/Service/SessionServiceProvider.php index 856ec3596..84d23d354 100644 --- a/system/src/Grav/Common/Service/SessionServiceProvider.php +++ b/system/src/Grav/Common/Service/SessionServiceProvider.php @@ -50,13 +50,17 @@ class SessionServiceProvider implements ServiceProviderInterface // Activate admin if we're inside the admin path. $is_admin = false; if ($config->get('plugins.admin.enabled')) { - $base = '/' . trim($config->get('plugins.admin.route'), '/'); + $admin_base = '/' . trim($config->get('plugins.admin.route'), '/'); // Uri::route() is not processed yet, let's quickly get what we need. $current_route = str_replace(Uri::filterPath($uri->rootUrl(false)), '', parse_url($uri->url(true), PHP_URL_PATH)); + // Test to see if path starts with a supported language + admin base + $lang = Utils::pathPrefixedByLangCode($current_route); + $lang_admin_base = '/' . $lang . $admin_base; + // Check no language, simple language prefix (en) and region specific language prefix (en-US). - if (Utils::startsWith($current_route, $base) || Utils::pathPrefixedByLangCode($current_route)) { + if (Utils::startsWith($current_route, $admin_base) || Utils::startsWith($current_route, $lang_admin_base)) { $cookie_lifetime = $config->get('plugins.admin.session.timeout', 1800); $enabled = $is_admin = true; }