Problem/Motivation
I am trying to use a YouTube playlist in a Remote Video Media entity. Every time I use a url like https://www.youtube.com/playlist?list=PLYqVYBTIm7u0HqkxEuemM9XqP1HN-PqMe
it spits out the error: The given URL does not match any known oEmbed providers.. The scheme is in the YouTube endpoint, but the non escapped question mark is returning a false negative on the RegEx inspection.
Steps to reproduce
Use any YouTube playlist url as a Remote Video Media Entity.
Proposed resolution
Patch to follow with fix.
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
Comment | File | Size | Author |
---|---|---|---|
#12 | 3222616-12-PASS.patch | 1.5 KB | phenaproxima |
#12 | 3222616-12-FAIL.patch | 878 bytes | phenaproxima |
#8 | interdiff_2-8.txt | 1.91 KB | vsujeetkumar |
#8 | 3222616-8.patch | 2.72 KB | vsujeetkumar |
#3 | 3222616_after_patch.png | 98.14 KB | hmendes |
Issue fork drupal-3222616
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
labboy0276 CreditAttribution: labboy0276 at Tandem commentedPatch to address the issue.
Comment #3
hmendes CreditAttribution: hmendes at CI&T 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 CreditAttribution: cilefen as a volunteer 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 CreditAttribution: vsujeetkumar at Srijan | A Material+ Company for Drupal India Association 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:
OEmbedTestTrait
andmedia_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 CreditAttribution: TomiMikola at Wunder 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 CreditAttribution: TomiMikola at Wunder 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?