OEmbed generates URLs with URL-decoded query string

Created on 29 October 2023, 8 months ago
Updated 24 April 2024, 2 months ago

Problem/Motivation

In πŸ› oembed link does not pass the URL parameter to the provider Fixed Drupal started URL-decoding the oEmbed URL to work-around a Vimeo oEmbed issue.

However, query parameters should always be URL-encoded, because it's a URL and that's what you do, and also because the oEmbed spec at https://oembed.com/ documents this; see e.g. http://flickr.com/services/oembed?url=http%3A%2F%2Fflickr.com%2Fphotos%2Fbees%2F2362225867%2F&format=json in the docs - the url query parameter is URL-encoded.

The missing URL-encoding was breaking things for me because I'm dealing with some oEmbed URLs that have a fragment such as #123123 at the end of the URL; this needs to be URL-encoded when part of the url query parameter or else it is interpreted as a fragment by guzzle HTTP client when sending the request (i.e. not sent as part of the request).

As documented at https://developer.vimeo.com/api/oembed/videos Vimeo has numerous query parameters which seem to be designed to be added directly to the oEmbed request itself, not to the URL which is part of that request, which you can see by comparing these oEmbed requests:

Note that https://developer.vimeo.com/api/oembed/videos also clearly documents several times that the query parameters should be URL-encoded, e.g. "NOTE: Be sure to URL-encode the url value."

So as far as I can tell, Vimeo requires some custom code to add these query parameters to the oEmbed request, which could happen either in core or a contrib module.

Steps to reproduce

Try to use OEmbed with URLs which require URL encoding to work, e.g. with URL fragments.

Proposed resolution

Revert πŸ› oembed link does not pass the URL parameter to the provider Fixed .

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

πŸ› Bug report
Status

Fixed

Version

10.2 ✨

Component
MediaΒ  β†’

Last updated about 21 hours ago

Created by

πŸ‡ΊπŸ‡ΈUnited States mfb San Francisco

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.69.0 2024