Merge branch 'mbstring-check' into release

pull/22/head
Paal Joergensen 2016-06-08 11:29:37 +02:00
commit d42630c369
1 changed files with 11 additions and 2 deletions

View File

@ -2898,7 +2898,12 @@ class H5PContentValidator {
// Check if string is within allowed length // Check if string is within allowed length
if (isset($semantics->maxLength)) { if (isset($semantics->maxLength)) {
$text = mb_substr($text, 0, $semantics->maxLength); if (!extension_loaded('mbstring')) {
$this->h5pF->setErrorMessage($this->h5pF->t('The mbstring PHP extension is not loaded. H5P need this to function properly'), 'error');
}
else {
$text = mb_substr($text, 0, $semantics->maxLength);
}
} }
// Check if string is according to optional regexp in semantics // Check if string is according to optional regexp in semantics
@ -2948,7 +2953,11 @@ class H5PContentValidator {
// file name, 2. testing against a returned error array that could // file name, 2. testing against a returned error array that could
// never be more than 1 element long anyway, 3. recreating the regex // never be more than 1 element long anyway, 3. recreating the regex
// for every file. // for every file.
if (!preg_match($wl_regex, mb_strtolower($file))) { if (!extension_loaded('mbstring')) {
$this->h5pF->setErrorMessage($this->h5pF->t('The mbstring PHP extension is not loaded. H5P need this to function properly'), 'error');
$valid = FALSE;
}
else if (!preg_match($wl_regex, mb_strtolower($file))) {
$this->h5pF->setErrorMessage($this->h5pF->t('File "%filename" not allowed. Only files with the following extensions are allowed: %files-allowed.', array('%filename' => $file, '%files-allowed' => $whitelist)), 'error'); $this->h5pF->setErrorMessage($this->h5pF->t('File "%filename" not allowed. Only files with the following extensions are allowed: %files-allowed.', array('%filename' => $file, '%files-allowed' => $whitelist)), 'error');
$valid = FALSE; $valid = FALSE;
} }