Summary

When an iframe URL is submitted without a protocol, a validation error occurs.

Remote providers often give iframe URLs without a leading protocol e.g:

//e.issuu.com/embed.html#foo

This can be necessary to support protocol switching, but apart from anything else people will cut and paste what their providers give them and not understand why it wouldn't work.

Steps to repeat

1. Add a generic media type
2. Add a protocol-free URL, plus width and height etc.
3. Submit

What happens

1. The media does not save
2. A validation error is triggered
3. The error text is "This value should be of the correct primitive type."
4. *All* textfields that are part of the iframe Drupal field are highlighted red.

3. and 4. make it tough to diagnose exactly what's going on and where, because they're not very specific, but as doing the same thing with the link beginning http:// instead of // causes the media to save, then I think this is the problem.

What should happen

1. The media should save
2. The resulting iframe will show on the page (and will show on other pages under different protocols.)

More suggestions

I appreciate protocol-relative URLs are arguably an anti-pattern: https://www.paulirish.com/2010/the-protocol-relative-url/ . But we need to make this user-friendly if possible.

One option is to detect protocol-relative URLs, and force them to be https before validation: any provider handing them out to people, should be able to support that! Another option is just to provide a more informative error message. I'd be open to suggestions!

Comments

jp.stacey created an issue. See original summary.

  • neffets committed 26c1d21 on 8.x-1.x
    Issue #2877627 by jp.stacey: Protocol-relative URLs cause a "primitive...
neffets’s picture

Assigned: Unassigned » neffets
Status: Active » Fixed

Drupal does not accept scheme-less urls. Please add "https:" to your url, this works on http-parent-pages too.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.