Merge branch 'develop' of github.com:getgrav/grav into feature/clockwork

# Conflicts:
#	CHANGELOG.md
This commit is contained in:
Matias Griese
2019-05-26 16:48:15 +03:00
3 changed files with 10 additions and 8 deletions

View File

@@ -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

View File

@@ -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;
}

View File

@@ -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;