Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,19 @@ public static function execute(string $url): array {
private static function get_meeting(string $url): ?stdClass {
global $DB;

$record = $DB->get_record('tiny_teamsmeeting', ['linkhash' => sha1($url)]);
// Normalise percent-encoding to uppercase before hashing so lookups
// succeed whether or not Moodle re-saved the HTML (which uppercases %xx).
$normalised = preg_replace_callback('/%[0-9a-f]{2}/i', fn($m) => strtoupper($m[0]), $url);
$record = $DB->get_record('tiny_teamsmeeting', ['linkhash' => sha1($normalised)]);

if (!$record) {
// Fallback for rows created before normalisation: try lowercase hex digits.
$lowercased = preg_replace_callback('/%[0-9A-F]{2}/', fn($m) => strtolower($m[0]), $normalised);
if ($lowercased !== $normalised) {
$record = $DB->get_record('tiny_teamsmeeting', ['linkhash' => sha1($lowercased)]);
}
}
Comment on lines +114 to +125

return $record ?: null;
}

Expand Down
15 changes: 15 additions & 0 deletions lib/editor/tiny/plugins/teamsmeeting/db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,5 +121,20 @@ function xmldb_tiny_teamsmeeting_upgrade($oldversion) {
upgrade_plugin_savepoint(true, 2025100207, 'tiny', 'teamsmeeting');
}

if ($oldversion < 2025100307.01) {
// Recompute linkhash using percent-encoding-normalised URLs so that
// hashes are stable regardless of whether Moodle has uppercased %xx
// sequences when saving HTML content (RFC 3986 normalisation).
$records = $DB->get_records('tiny_teamsmeeting', null, 'id ASC', 'id, link');
foreach ($records as $record) {
$normalised = preg_replace_callback('/%[0-9a-f]{2}/i', fn($m) => strtoupper($m[0]), $record->link);
$DB->set_field('tiny_teamsmeeting', 'linkhash', sha1($normalised), ['id' => $record->id]);
$DB->set_field('tiny_teamsmeeting', 'link', $normalised, ['id' => $record->id]);
}
unset($records);

upgrade_plugin_savepoint(true, 2025100307.01, 'tiny', 'teamsmeeting');
}
Comment on lines +124 to +137

return true;
}
21 changes: 18 additions & 3 deletions lib/editor/tiny/plugins/teamsmeeting/result.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,31 @@
$courseid = optional_param('courseid', 0, PARAM_INT);
$viewexisting = optional_param('viewexisting', 0, PARAM_INT);
$meetinglink = optional_param('link', null, PARAM_URL);
// Normalise percent-encoding to uppercase (RFC 3986) so the SHA1 hash is
// stable regardless of whether Moodle has re-saved the HTML (which uppercases
// %xx sequences) since the meeting was first created.
if ($meetinglink !== null) {
$meetinglink = preg_replace_callback('/%[0-9a-f]{2}/i', fn($m) => strtoupper($m[0]), $meetinglink);
}
$title = optional_param('title', null, PARAM_TEXT);
$preview = optional_param('preview', null, PARAM_CLEANHTML);
$optionslink = optional_param('options', null, PARAM_URL);
$session = optional_param('session', '', PARAM_ALPHANUM);

if ($viewexisting) {
require_sesskey();
$viewrecord = $meetinglink
? $DB->get_record('tiny_teamsmeeting', ['linkhash' => sha1($meetinglink)])
: null;
if ($meetinglink) {
$viewrecord = $DB->get_record('tiny_teamsmeeting', ['linkhash' => sha1($meetinglink)]);
if (!$viewrecord) {
// Fallback for rows stored before normalisation (lowercase hex in %xx sequences).
$lowercased = preg_replace_callback('/%[0-9A-F]{2}/', fn($m) => strtolower($m[0]), $meetinglink);
if ($lowercased !== $meetinglink) {
$viewrecord = $DB->get_record('tiny_teamsmeeting', ['linkhash' => sha1($lowercased)]);
}
}
} else {
$viewrecord = null;
}
$context = ($viewrecord && !empty($viewrecord->contextid))
? context::instance_by_id($viewrecord->contextid)
: context_system::instance();
Expand Down
4 changes: 2 additions & 2 deletions lib/editor/tiny/plugins/teamsmeeting/version.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@

defined('MOODLE_INTERNAL') || die();

$plugin->version = 2025100306;
$plugin->version = 2025100307.01;
$plugin->requires = 2025040800;
$plugin->release = '5.0.6';
$plugin->release = '5.0.7';
Comment on lines +28 to +30
$plugin->component = 'tiny_teamsmeeting';
$plugin->maturity = MATURITY_STABLE;