From a6656c2e6ffb14c4083c058065ff8fb2d4426365 Mon Sep 17 00:00:00 2001 From: Frode Petterson Date: Mon, 20 Jun 2016 14:57:14 +0200 Subject: [PATCH 1/4] Support for when cookies are disabled HFJ-1915 --- js/h5p-x-api-event.js | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/js/h5p-x-api-event.js b/js/h5p-x-api-event.js index c5ce2e3..212fe0b 100644 --- a/js/h5p-x-api-event.js +++ b/js/h5p-x-api-event.js @@ -24,7 +24,7 @@ H5P.XAPIEvent.prototype.constructor = H5P.XAPIEvent; */ H5P.XAPIEvent.prototype.setScoredResult = function (score, maxScore, instance, completion, success) { this.data.statement.result = {}; - + if (typeof score !== 'undefined') { if (typeof maxScore === 'undefined') { this.data.statement.result.score = {'raw': score}; @@ -40,22 +40,22 @@ H5P.XAPIEvent.prototype.setScoredResult = function (score, maxScore, instance, c } } } - + if (typeof completion === 'undefined') { this.data.statement.result.completion = (this.getVerb() === 'completed' || this.getVerb() === 'answered'); } else { this.data.statement.result.completion = completion; } - + if (typeof success !== 'undefined') { this.data.statement.result.success = success; } - + if (instance && instance.activityStartTime) { var duration = Math.round((Date.now() - instance.activityStartTime ) / 10) / 100; // xAPI spec allows a precision of 0.01 seconds - + this.data.statement.result.duration = 'PT' + duration + 'S'; } }; @@ -188,12 +188,18 @@ H5P.XAPIEvent.prototype.setActor = function () { } else { var uuid; - if (localStorage.H5PUserUUID) { - uuid = localStorage.H5PUserUUID; + try { + if (localStorage.H5PUserUUID) { + uuid = localStorage.H5PUserUUID; + } + else { + uuid = H5P.createUUID(); + localStorage.H5PUserUUID = uuid; + } } - else { - uuid = H5P.createUUID(); - localStorage.H5PUserUUID = uuid; + catch (err) { + // LocalStorage and Cookies are probably disabled. Do not track the user. + uuid = 'not-trackable-' + H5P.createUUID(); } this.data.statement.actor = { 'account': { From 8cb0aad09e0c6dc0ade4bcea665074783370988c Mon Sep 17 00:00:00 2001 From: andyrandom Date: Tue, 21 Jun 2016 09:34:27 +0200 Subject: [PATCH 2/4] Allow hyphens in HTML tags HFJ-1951 --- h5p.classes.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/h5p.classes.php b/h5p.classes.php index 93c4213..46af520 100644 --- a/h5p.classes.php +++ b/h5p.classes.php @@ -3414,7 +3414,7 @@ class H5PContentValidator { return '<'; } - if (!preg_match('%^<\s*(/\s*)?([a-zA-Z0-9]+)([^>]*)>?|()$%', $string, $matches)) { + if (!preg_match('%^<\s*(/\s*)?([a-zA-Z0-9\-]+)([^>]*)>?|()$%', $string, $matches)) { // Seriously malformed. return ''; } From 406a55be5ca4c4f3f85a4a12c82bd4c1e53a9356 Mon Sep 17 00:00:00 2001 From: ndobromirov Date: Tue, 21 Jun 2016 13:26:39 +0200 Subject: [PATCH 3/4] Excessive calls to variable_set HFJ-1893 --- h5p.classes.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/h5p.classes.php b/h5p.classes.php index 7e58d6c..1021375 100644 --- a/h5p.classes.php +++ b/h5p.classes.php @@ -2344,7 +2344,7 @@ class H5PCore { * rebuilt only if non-existing */ public function validateLibrarySupport($force = false) { - if (!($this->h5pF->getUnsupportedLibraries() === NULL || $force)) { + if (!$force && $this->h5pF->getUnsupportedLibraries() !== NULL) { return; } @@ -2379,9 +2379,8 @@ class H5PCore { ); } } - - $this->h5pF->setUnsupportedLibraries(empty($unsupportedLibraries) ? NULL : $unsupportedLibraries); } + $this->h5pF->setUnsupportedLibraries($unsupportedLibraries); } /** From 3d14588160ef72d44098902aa0426c94267cf6eb Mon Sep 17 00:00:00 2001 From: Frode Petterson Date: Fri, 8 Jul 2016 11:08:47 +0200 Subject: [PATCH 4/4] Bugfix: Check if library json is valid --- h5p-development.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/h5p-development.class.php b/h5p-development.class.php index 546ced0..6c891f9 100644 --- a/h5p-development.class.php +++ b/h5p-development.class.php @@ -78,7 +78,7 @@ class H5PDevelopment { } $library = json_decode($libraryJSON, TRUE); - if ($library === FALSE) { + if ($library === NULL) { continue; // Invalid JSON. }