fixed issue with premium key not properly handling unicode spaces in key wrappers

This commit is contained in:
PMKuipers 2024-05-22 21:46:56 +02:00
parent 50110a3e0f
commit 39d184c2e9
9 changed files with 30 additions and 11920 deletions

View File

@ -9,7 +9,6 @@
"spellright.documentTypes": [ "spellright.documentTypes": [
"markdown", "markdown",
"latex", "latex",
"plaintext", "plaintext"
"php"
] ]
} }

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -115,13 +115,16 @@ Klc5I28bGbvxIV5pnL6ZSjHEDp2WreM8HB0XFJwU+Q==
$start = -1; $start = -1;
$end = -1; $end = -1;
for($i = 0; $i < count($parts); $i++) { for($i = 0; $i < count($parts); $i++) {
if ( $parts[$i] == $START_HEADER ) { $p = trim(preg_replace('/\s+/u', ' ', $parts[$i])); // Make sure all unicode spaces are converted to normal spaces before comparing...
if ( $p == $START_HEADER ) {
$start = $i+1; $start = $i+1;
} }
if ($start > 0 && $parts[$i] == $END_HEADER) { if ($start > 0 && $p == $END_HEADER) {
$end = $i; $end = $i;
} }
} }
if ($start < 0 || $end < 0 || $end - $start <= 0) { if ($start < 0 || $end < 0 || $end - $start <= 0) {
throw new \ValueError("Invalid activation key wrappers"); throw new \ValueError("Invalid activation key wrappers");
} else { } else {
@ -277,8 +280,9 @@ Klc5I28bGbvxIV5pnL6ZSjHEDp2WreM8HB0XFJwU+Q==
private static function website_match($key) { private static function website_match($key) {
global $CFG; global $CFG;
$site = $CFG->wwwroot; $site = $CFG->wwwroot;
// Add double slashes to key and site if no scheme is set. // Add double slashes to key and site if no scheme is set.
// Basically: if no double slashes present before any dots,shashes or @s. // Basically: if no double slashes present before any dots,slashes or @s.
if(!\preg_match_all('#^[^./@]*?//#',$key )) { if(!\preg_match_all('#^[^./@]*?//#',$key )) {
$key = "//".$key; $key = "//".$key;
} }

View File

@ -565,10 +565,12 @@ class studentstudyplanservice extends \external_api {
$list = []; $list = [];
foreach ($records as $r) { foreach ($records as $r) {
$studyplan = studyplan::find_by_id($r->studyplan_id); try {
if (has_capability(self::CAP_COACH,$studyplan->context(),$USER)) { $studyplan = studyplan::find_by_id($r->studyplan_id);
$list[] = $studyplan->simple_model_coach(); if (has_capability(self::CAP_COACH,$studyplan->context(),$USER)) {
} $list[] = $studyplan->simple_model_coach();
}
} catch(\Exception $x) {}
} }
return $list; return $list;
} }

View File

@ -499,9 +499,17 @@ class studyplan {
if ($DB->count_records('local_treestudyplan_page', ['studyplan_id' => $this->id]) > 0) { if ($DB->count_records('local_treestudyplan_page', ['studyplan_id' => $this->id]) > 0) {
return success::fail('cannot delete studyplan that still has pages'); return success::fail('cannot delete studyplan that still has pages');
} else { } else {
// Delete any coach links for this studyplan before deleting the studyplan itself.
$DB->delete_records("local_treestudyplan_coach", ["studyplan_id" => $this->id]);
// TODO: Check if students and cohorts need to be removed at this time too..
$DB->delete_records("local_treestudyplan_cohort", ["studyplan_id" => $this->id]);
//
$DB->delete_records("local_treestudyplan_user", ["studyplan_id" => $this->id]);
//
$DB->delete_records('local_treestudyplan', ['id' => $this->id]); $DB->delete_records('local_treestudyplan', ['id' => $this->id]);
return success::success(); return success::success();
} }
} }
/** /**

View File

@ -1,5 +1,5 @@
<?php <?php
// This file is part of the Studyplan plug-in for Moodle // This file is part of the study plan plug-in for Moodle
// //
// Moodle is free software: you can redistribute it and/or modify // Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by // it under the terms of the GNU General Public License as published by

View File

@ -1,5 +1,5 @@
<?php <?php
// This file is part of the Studyplan plugin for Moodle // This file is part of the study plan plugin for Moodle
// //
// Moodle is free software: you can redistribute it and/or modify // Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by // it under the terms of the GNU General Public License as published by
@ -25,8 +25,8 @@ $plugin->component = 'local_treestudyplan'; // Recommended since 2.0.2 (MDL-260
$plugin->version = 2024051800; // YYYYMMDDHH (year, month, day, iteration). $plugin->version = 2024051800; // YYYYMMDDHH (year, month, day, iteration).
$plugin->requires = 2021051700; // YYYYMMDDHH (This is the release version for Moodle 3.11). $plugin->requires = 2021051700; // YYYYMMDDHH (This is the release version for Moodle 3.11).
$plugin->release = "1.2.0"; $plugin->release = "1.3.0";
$plugin->maturity = MATURITY_BETA; /*MATURITY_STABLE;*/ $plugin->maturity = MATURITY_STABLE; /*MATURITY_STABLE;*/
// Supported from Moodle 3.11 to 4.3. // Supported from Moodle 3.11 to 4.3.
$plugin->supported = [ 311, 403]; $plugin->supported = [ 311, 403];