dreamwidth/dw-free — pull request #469 by rickscott (2013-07-01 04:06:57+00:00)
Title: (bug 5149) allow network-rel URLs in YT embeds

http://bugs.dwscoalition.org/show_bug.cgi?id=5149

Youtube has started using network-relative URLs in its embed codes, eg src="//www.youtube.com/...". This is a legit but uncommon syntax -- it means "fetch this location, using the same protocol as you used for this page" -- eg http for http, https for https.

This patch updates the allow_iframe_embeds hook to permit URLs of this form. Unfortunately, the URI module can't cope with them, so we have to lie to it about the URL scheme to get the rest of its parsing to work. We don't modify the URL that's actually used to do the embedding, though -- just what's used for checks inside the hook.

We also tune up the regex used to provide accessibility links for Youtube videos in cgi-bin/LJ/EmbedModule.pm so that that feature continues to work with network-relative URLs.

Feedback appreciated, in particular with how I wrote out the Youtube URL matching regex in EmbedModule.pm. Is it clearer using extended format? Is it overbroad?