CodeIgniter icon indicating copy to clipboard operation
CodeIgniter copied to clipboard

Always default language will load in Lang.php CI3

Open mpouyandeh opened this issue 11 years ago • 1 comments

I was just testing CI 3 and I think there is a little bug in system/core/Lang.php on line 109

if (empty($idiom) OR ! preg_match('/^[a-z_-]$/i', $idiom))

This condition is always true, check out this example :

$idiom = 'english';
if (empty($idiom) OR ! preg_match('/^[a-z_-]$/i', $idiom)) {
    echo 'load default language';
}

This will print "load default language" (I think code is clear enough so I don't write a complete CI example) The issue is the regex used in condition I did not know how to edit and fix it so I opened an issue

mpouyandeh avatar Jan 10 '15 20:01 mpouyandeh

I confirm. This is what I see as a fix:

if (empty($idiom) OR ! preg_match('/^[a-z_-]+$/i', $idiom))

ivantcholakov avatar Jan 10 '15 21:01 ivantcholakov