H5P Iframe Embedder URL with space results in 404
Hello,
I have detected a problem with H5P Iframe Embedder working on Moodle. If I set a URL to a PDF that has a space in the filename and I store it in a moodle folder, H5P gives an error and does not show the content, resulting in 404 Not Found.
Steps to replicate it:
- Create a test course on demo.moodle.net (Moodle 4.0.4)
- In the course, create a folder resource and upload a pdf named "test file.pdf" (blank space important).
- Get the URL to the PDF by accessing the folder resource and right clicking on the file / copy link.
- Example link: https://sandbox.moodledemo.net/pluginfile.php/63/mod_folder/content/0/test%20flle.pdf?forcedownload=1 (note the space coded as %20).
- In the test course, create an H5P activity of type Iframe Embedder, set a title and in src indicate the URL: https://sandbox.moodledemo.net/pluginfile.php/63/mod_folder/content/0/test%20flle.pdf?forcedownload=1
- Save and access the activity.
- A 404 error will be displayed in DevTools (chrome. Firefox also fails).
In DevTools, if you analyze the URL that is being used to embed, you can find that it is encoding the %20 part of the URL as %2520. I think it encodes the original % itself as %25, resulting in %2520 and this is finally not recognized correctly and 404 is returned.
Actually, I detected the problem using the Interactive Book activity and in this one using Iframe Embedder, but in the end the problem seems to be in the latter.
This happens in Moodle 3.9.15, 3.11.8 and also in 4.0.4.
Greetings and thanks
otacke
Mon, 11/21/2022 - 15:53
Permalink
Hi!The iframe embedder in
Hi!
The iframe embedder in fact encodes the URI that is provided. Just enter the URL with a space instead of %20 and you should be good to go.
Best,
Oliver
jmabreu
Tue, 11/22/2022 - 09:33
Permalink
could the component stop altering the URL entered by the user?
Hi Oliver,
thanks, we also noticed what you said.
We have to take into account that the teacher normally does not write the URL by hand, he copies it from another site and that URL should be correct, it has the spaces encoded and does not require modification.
In this case, so that the teacher did not have to edit the URL, what we suggested was to remove the spaces in the filename of the uploaded file in moodle and then copy the URL, however, it is still something "weird" that the teacher must do it this way.
Actually, I was just trying to report it in case it was feasible for the H5P component to stop altering the URL in this way, with the intention that the user would only have to copy and paste a URL without paying attention to character encoding issues.
Regards
otacke
Tue, 11/22/2022 - 15:30
Permalink
Hi jmabreu!I am merely a
Hi jmabreu!
I am merely a community member who mentioned a potential workaround. Handling this still falls into the hands of the H5P core team that I am not a part of.
Cheers,
Oliver
BV52
Tue, 11/22/2022 - 18:07
Permalink
Hi All,I don't think the
Hi All,
I don't think the development team will fix this "issue" since development for this content type has stopped a few years back. In reality we do not recommned using Iframe embedder due to accessibility, unresponsiveness, security and privacy concerns.
-BV
jmabreu
Wed, 11/23/2022 - 10:06
Permalink
Ok, thank you for your time
Hi,
ok, thank you for your time, we will take it into account.
Regards