From a78bf06aef7d050dc3ba7783408ab8e95c404399 Mon Sep 17 00:00:00 2001 From: Maximilian Haye Date: Thu, 14 Sep 2023 16:03:33 +0200 Subject: [PATCH] fix: correctly mangle img/@usemap --- classes/question_ui_renderer.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/classes/question_ui_renderer.php b/classes/question_ui_renderer.php index 04cf20ce..7eec55ee 100644 --- a/classes/question_ui_renderer.php +++ b/classes/question_ui_renderer.php @@ -342,7 +342,12 @@ private function mangle_ids_and_names(\DOMXPath $xpath, question_attempt $qa): v //xhtml:img/@usemap ") as $attr) { $original = $attr->value; - $attr->value = $qa->get_qt_field_name($original); + if ($attr->name === "usemap" && utils::str_starts_with($original, "#")) { + // See https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/useMap. + $attr->value = "#" . $qa->get_qt_field_name(substr($original, 1)); + } else { + $attr->value = $qa->get_qt_field_name($original); + } } }