From 41ed0c18e4fa2ccec5c89958a1237554e759005b Mon Sep 17 00:00:00 2001 From: Svein-Tore Griff With Date: Sun, 2 Nov 2014 17:52:39 +0100 Subject: [PATCH 1/2] Add htmlSpecialChars --- h5p.classes.php | 2 +- js/h5p.js | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/h5p.classes.php b/h5p.classes.php index 7d964ba..b4fc7a7 100644 --- a/h5p.classes.php +++ b/h5p.classes.php @@ -1526,7 +1526,7 @@ class H5PCore { public static $coreApi = array( 'majorVersion' => 1, - 'minorVersion' => 3 + 'minorVersion' => 4 ); public static $styles = array( 'styles/h5p.css', diff --git a/js/h5p.js b/js/h5p.js index d53f8e2..fe257f2 100644 --- a/js/h5p.js +++ b/js/h5p.js @@ -1099,3 +1099,10 @@ if (H5P.jQuery) { } }); } + + /** + * Mimics how php's htmlspecialchars works (the way we use it) + */ +H5P.htmlSpecialChars = function(string) { + return string.toString().replace(//g, '>').replace(/'/g, ''').replace(/"/g, '"'); +}; \ No newline at end of file From 7c3ddea71a7431ec455597260759583019740e50 Mon Sep 17 00:00:00 2001 From: Svein-Tore Griff With Date: Sun, 2 Nov 2014 19:13:14 +0100 Subject: [PATCH 2/2] Become node_clone compatible again --- h5p.classes.php | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/h5p.classes.php b/h5p.classes.php index b4fc7a7..e77258c 100644 --- a/h5p.classes.php +++ b/h5p.classes.php @@ -1648,19 +1648,23 @@ class H5PCore { // Update content dependencies. $content['dependencies'] = $validator->getDependencies(); - $this->h5pF->deleteLibraryUsage($content['id']); - $this->h5pF->saveLibraryUsage($content['id'], $content['dependencies']); - if ($this->exportEnabled) { - // Recreate export file - $exporter = new H5PExport($this->h5pF, $this); - $exporter->createExportFile($content); + // Sometimes the parameters are filtered before content has been created + if ($content['id']) { + $this->h5pF->deleteLibraryUsage($content['id']); + $this->h5pF->saveLibraryUsage($content['id'], $content['dependencies']); - // TODO: Should we rather create the file once first accessed, like imagecache? + if ($this->exportEnabled) { + // Recreate export file + $exporter = new H5PExport($this->h5pF, $this); + $exporter->createExportFile($content); + + // TODO: Should we rather create the file once first accessed, like imagecache? + } + + // Cache. + $this->h5pF->setFilteredParameters($content['id'], $params); } - - // Cache. - $this->h5pF->setFilteredParameters($content['id'], $params); return $params; }