-
Bug
-
Resolution: Fixed
-
Major
-
4.1.4
-
MOODLE_401_STABLE
-
MOODLE_401_STABLE, MOODLE_402_STABLE
-
MDL-78895-401 -
Summary:
The changes from https://github.com/moodle/moodle/commit/8d8af19af0fd3560ecbefed9db44649783e79837 (MDL-78452) have caused a couple of regressions:
- Ampersands are double encoded because of this - same workaround as here required
- The previous $extra attributes have been lost, used for displaying the link in a popup or new window
Original report
I recently upgraded from 3.9 to 4.1.4+ (Build: 20230714) - update, the 4.1.5 is the same
Course format/Course layout is one section per page.
In course I had activity/resource URL (external, though it is not) referring to the certain section of my course. Something like https://mymoodle.site/course/view.php?id=9§ion=3
The same link I added to the Description part. When checking the HTML code, it seems the & character is replaced with "& a m p ;" sequence.
The result is, that when displaying this activity/resource "page" (https://mymoodle.site/mod/url/view.php?id=963&forceview=1), the link from description works fine, but link from field of External URL displays as https://mymoodle.site/course/view.php?id=903& a m p ;section=6 and takes me only on the course (overview/front) page https://mymoodle.site/course/view.php?id=903
(I added spaces above)
It worked in 3.9., it works in 4.1.2+ (Build: 20230418). Searching moodle.git, 4.1.3 is the same as 4.1.2.
This behaviour affects links saved before upgrade and new ones as well.
Change between versions is in /moodle/mod/url/locallib.php (lines 280 and 301).
I tried to replace the /moodle/mod/url/locallib.php in 4.1.4 with file from 4.1.2 (I have test environment). I see it works well. The working one displays url, the corrupted one displays name (looks nicer, but is not working). But it is not a solution.
Update: Done some more tests. When I reported bug, I had Automatic Appearance. Now I have tested each possible appearance (Embed, Open, In pop-up) and Embed, and only Embed works with url-s containing "&". It is because it uses content of variable $fullurl. "Open" uses "html_writer::link" which somehow does no good when used with "print_string".
Until it is resolved, I replace line 280 in /moodle/mod/url/locallib.php:
print_string('clicktoopen', $fullurl , html_writer::link($fullurl, format_string($cm->name)));
with:
print_string('clicktoopen', 'url', "<a href=\"$fullurl\" $extra>$cm->name</a>");
- is a regression caused by
-
MDL-78542 mod_url link texts are shown as URL instead of a human-readable text
- Closed
- is duplicated by
-
MDL-79412 Url resources are double encoded
- Closed
-
MDL-79513 Link activities altering ampersands in URLs
- Closed
-
MDL-79556 Problem with character conversion in a complex url
- Closed
-
MDL-79624 URL resource display options "New window" and "In pop-up" display as "Open" when opened from within the resource
- Closed
- Testing discovered
-
MDL-79283 The URL resource embedded iframe must have an accessible name
- Closed