From e6ddaa5b3012ea95dd5c0e4c2c8a2cd2414a7966 Mon Sep 17 00:00:00 2001 From: Mark Nelson Date: Mon, 9 Mar 2020 14:48:24 +0100 Subject: [PATCH] Do not allow '0' as a value for width or height in QR code (#321) --- element/qrcode/classes/element.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/element/qrcode/classes/element.php b/element/qrcode/classes/element.php index 0851221..0453ce4 100644 --- a/element/qrcode/classes/element.php +++ b/element/qrcode/classes/element.php @@ -72,8 +72,12 @@ class element extends \mod_customcert\element { $errors = []; // Check if height is not set, or not numeric or less than 0. - if ((!isset($data['height'])) || (!is_numeric($data['height'])) || ($data['height'] < 0)) { - $errors['height'] = get_string('invalidheight', 'customcertelement_qrcode'); + if ((!isset($data['height'])) || (!is_numeric($data['height'])) || ($data['height'] <= 0)) { + $errors['height'] = get_string('invalidheight', 'mod_customcert'); + } + + if ((!isset($data['width'])) || (!is_numeric($data['width'])) || ($data['width'] <= 0)) { + $errors['width'] = get_string('invalidwidth', 'mod_customcert'); } if ($this->showposxy) {