Closed (fixed)
Project:
Drupal core
Version:
9.2.x-dev
Component:
media system
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
7 Jul 2021 at 14:35 UTC
Updated:
24 Nov 2023 at 11:52 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
labboy0276 commentedPatch to address the issue.
Comment #3
hmendes commentedTested patch from #2 and it fixed my problem.
I added a media field as Remote Video and tried to create a new node adding the url https://www.youtube.com/playlist?list=PLYqVYBTIm7u0HqkxEuemM9XqP1HN-PqMe on the media field and it showed the error on 3222616_before_patch.png, after applying the patch it worked and I could create the node.
Changing to RTBC.
Comment #4
cilefen commentedThere are a few potential places to add test coverage:
Comment #5
xjm9.1.x is also security fixes only at this point.
Thanks for the bug report and proposed fix!
Comment #6
larowlanAny reason this doesn't use preq_quote?
Comment #7
phenaproximaRemoving redundant tag.
Comment #8
vsujeetkumar commentedTest added, Please have a look.
Comment #9
phenaproximaThanks for writing that test, @vsujeetkumar!!
There is one issue with it, though: it looks like it's making an actual request for a real YouTube playlist. That's troublesome because, if YouTube went down (or that playlist disappeared), our tests would start failing. It's therefore imperative that core tests do NOT make real requests to the Internet.
I can see two ways to correct this:
OEmbedTestTraitandmedia_test_oembed, plus a new fixture representing a YouTube playlist, to make the test run offline. This way is a bit tricky to implement, but an example of it can be seen inDrupal\Tests\media\Functional\FieldFormatter::testRender().Endpoint::matchUrl()method, and tests to ensure it handles the question mark correctly.Sending back to "needs work" to, at the very least, adjust the test, which IMHO is the only thing that blocks commit here. My preference would be to convert the test to a unit test, but you can keep it as a functional test if that's what you're more comfortable with. The main requirement is that the test must be able to run, and pass, offline.
Comment #10
phenaproximaOn second thought, let's go with a unit test here. I think that it will be much simpler to write, it'll run orders of magnitude faster than a functional test, and it's guaranteed to pass offline. :) All the test needs to do, to be clear, is:
$this->createMock()is good for this)Ideally we should use some of the YouTube endpoint info from https://oembed.com/providers.json to create the fake endpoint, for added realism.
Comment #11
phenaproximaComment #12
phenaproximaWrote the unit test. Here's a pass/fail patch for proof, and I've committed the changes to the merge request.
Comment #15
marcoscanoReviewed the patch and the test, and both look good to me. Thanks!
Comment #18
catchCommitted/pushed to 9.3.x and cherry-picked to 9.2.x, thanks!
Comment #20
tomimikola commentedHi! There seems to still be a minor issue accepting the playlist URLs.
When copying the URL from the browser address bar the format is accepted since it contains "www." but when copied from the Share-button modal the URL is without the "www." and will throw "The given URL does not match any known oEmbed providers" error.
How to reproduce?
Comment #21
tomimikola commentedRegarding the comment #20 I made a PR to the oembed provider list to handle the non-www playlist URLs: https://github.com/iamcal/oembed/pull/598
Nothing to do here in Drupal. Only to wait the provider list hopefully updates.
Comment #22
eduardo morales albertiWhen we try to embed using the URL "https://youtube.com/playlist?list=PLpeDXSh4nHjRbK4e6xsJ5-EFkDLOAPYfc" we get the error:
"Refused to frame 'http://mysite.docker.localhost:8000/' because an ancestor violates the following Content Security Policy directive: "frame-ancestors 'none'"."
But if we change to URL "https://www.youtube.com/embed/videoseries?list=PLpeDXSh4nHjRbK4e6xsJ5-EF..." then the video list is shown.
Any clue?