Return false if the string is less than 4 chars, it cannot contain the lang code. Prevents error in the method

This commit is contained in:
Flavio Copes
2016-01-07 14:34:13 +01:00
parent 5fefa85f4a
commit 51d2724dfd

View File

@@ -379,6 +379,10 @@ abstract class Utils
*/
public static function pathPrefixedByLangCode($string)
{
if (strlen($string) <= 3) {
return false;
}
$languages_enabled = self::getGrav()['config']->get('system.languages.supported', []);
if ($string[0] == '/' && $string[3] == '/' && in_array(substr($string, 1, 2), $languages_enabled)) {