From 832aebf5e07aea6986426c2291a56485385923b3 Mon Sep 17 00:00:00 2001 From: Frode Petterson Date: Fri, 29 Jul 2016 14:15:00 +0200 Subject: [PATCH] Moved regexp from editor to core HFJ-2099 --- h5p.classes.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/h5p.classes.php b/h5p.classes.php index 5829b20..7b30f51 100644 --- a/h5p.classes.php +++ b/h5p.classes.php @@ -1738,6 +1738,9 @@ class H5PCore { $this->detectSiteType(); $this->fullPluginPath = preg_replace('/\/[^\/]+[\/]?$/', '' , dirname(__FILE__)); + + // Standard regex for converting copied files paths + $this->relativePathRegExp = '/^((\.\.\/){1,2})(.*content\/)?(\d+|editor)\/(.+)$/'; } /** @@ -2938,8 +2941,8 @@ class H5PContentValidator { private function _validateFilelike(&$file, $semantics, $typeValidKeys = array()) { // Do not allow to use files from other content folders. $matches = array(); - if (preg_match('/^(\.\.\/){1,2}(.*content\/)?(\d+|editor)\/(.+)$/', $file->path, $matches)) { - $file->path = $matches[4]; + if (preg_match($this->h5pC->relativePathRegExp, $file->path, $matches)) { + $file->path = $matches[5]; } // Make sure path and mime does not have any special chars