From 673033460ef2344ad27f6ed7aa46585b3f5bc8b1 Mon Sep 17 00:00:00 2001 From: "hendrik.donath" <Donath@itc.rwth-aachen.de> Date: Fri, 14 Apr 2023 13:10:17 +0200 Subject: [PATCH] moved the query for comments into a section that is always about a comment, check if id is an int value --- lib.php | 18 +++++------------- version.php | 2 +- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/lib.php b/lib.php index 1031060..fdce7be 100644 --- a/lib.php +++ b/lib.php @@ -375,19 +375,10 @@ function pdfannotator_pluginfile($course, $cm, $context, $filearea, $args, $forc // Intro is handled automatically in pluginfile.php. return false; } - - // $commentid = 0; - // foreach ($args as $param) { - // if ($DB->record_exists('pdfannotator_comments', ['id' => $param])) { - // $commentid = $param; - // break; - // } - // } - array_shift($args); // Ignore revision - designed to prevent caching problems only. - $fs = get_file_storage(); - $relativepath = implode('/', $args); if ($filearea === 'content') { + array_shift($args); // Ignore revision - designed to prevent caching problems only. + $relativepath = implode('/', $args); $fullpath = rtrim("/$context->id/mod_pdfannotator/$filearea/0/$relativepath", '/'); do { if (!$file = $fs->get_file_by_hash(sha1($fullpath))) { @@ -425,12 +416,13 @@ function pdfannotator_pluginfile($course, $cm, $context, $filearea, $args, $forc if ($filearea === 'post') { $commentid = 0; foreach ($args as $param) { - if (is_int($param) && $DB->record_exists('pdfannotator_comments', ['id' => $param])) { + if (filter_var($param, FILTER_VALIDATE_INT) && $DB->record_exists('pdfannotator_comments', ['id' => $param])) { $commentid = $param; break; } } - + array_shift($args); + $relativepath = implode('/', $args); $fullpath = rtrim("/$context->id/mod_pdfannotator/$filearea/$commentid/$relativepath", '/'); if (!$file = $fs->get_file_by_hash(sha1($fullpath)) or $file->is_directory()) { //Annotations from other documents might have another contextid. diff --git a/version.php b/version.php index cc17a42..3e4e929 100644 --- a/version.php +++ b/version.php @@ -25,7 +25,7 @@ defined('MOODLE_INTERNAL') || die(); $plugin->component = 'mod_pdfannotator'; -$plugin->version = 2022120500; +$plugin->version = 2023041400; $plugin->release = 'PDF Annotator v1.5 release 3'; $plugin->requires = 2021051700; $plugin->maturity = MATURITY_STABLE; -- GitLab