Media Enclosure Url is Double-Escaped

Created on 12 January 2021, almost 4 years ago
Updated 10 April 2024, 8 months ago

Problem/Motivation

A podcast media file which contains spaces (or other special characters) does not load in a podcast app because the URL gets double-escaped and is therefore not valid. This is because views has already escaped the uri before it is passed to Url::fromUserInput in buildElementForLink.

Eg. '.../name with spaces.mp3' should become '.../name%20with%20spaces.mp3' but becomes '.../name%2520with%2520spaces.mp3'

Steps to reproduce

  • Use field_audio_file for the media file in episode content type.
  • Add the audio file field to the feed rss and choose this in Podcast Field Settings (Url Field in Audio File Settings)
  • Add an episode with an audio file that has special characters in its filename
  • The rss feed shows an enclosure with an invalid url

Proposed resolution

For now, I solved my problem by running the uri through urldecode before the call to Url::fromUserInput.

That is, altering line 71 in PodcastViewsMappingsTrait.php to:

$link_input = urldecode('/' . ltrim($value, '/'));

It strikes me that someone who understands the code better may be able to suggest a more elegant solution...

🐛 Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

🇬🇧United Kingdom imonemus

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

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024