Handle invalid value from LanguageNameIndexer::getLanguageData
Check preg_match return for failure and also check json_decode for failure by checking for the index key needed for further processing. Change-Id: Ifecf3fdaf476a05d0dc6fc1c40c3d8a2aa0fa88b
This commit is contained in:
@@ -145,9 +145,14 @@ class LanguageNameIndexer extends Maintenance {
|
||||
private function getLanguageData() {
|
||||
$file = __DIR__ . '/../lib/jquery.uls/src/jquery.uls.data.js';
|
||||
$contents = file_get_contents( $file );
|
||||
preg_match( '/.*\$\.uls\.data = (.*?)} \( jQuery \)/s', $contents, $matches );
|
||||
if ( !preg_match( '/.*\$\.uls\.data = (.*?)} \( jQuery \)/s', $contents, $matches ) ) {
|
||||
throw new LogicException( 'Syntax error in jquery.uls.data.js?' );
|
||||
}
|
||||
$json = $matches[ 1 ];
|
||||
$data = json_decode( $json, true );
|
||||
if ( !$data ) {
|
||||
throw new LogicException( 'json_decode failed. Syntax error in jquery.uls.data.js?' );
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user