kevincox / youtube-e2l

A Firefox addon to replace YouTube embeds with links to the video.
https://addons.mozilla.org/en-US/firefox/addon/youtube-embed2link/
Apache License 2.0
4 stars 3 forks source link

Ampersands(&) in URL causing YouTube app to reject the link #8

Closed JLJTGR closed 10 years ago

JLJTGR commented 10 years ago

I don't know if these embed URLs are "valid" or not, but I found them in the wild...

Take the following raw URL:

http://www.youtube.com/v/qwertyuiop&hl=en_US&fs=1&rel=0

This gets converted to: (or something to that effect)

vnd.youtube:qwertyuiop&hl=en_US&fs=1&rel=0

In embed2yt.js, lines 31 and 32... if you add an ampersand(&) to the negated character class, it will properly remove the parameters for this syntax style and allow the YouTube app to accept the link.

var ytre = new RegExp("^(https?://)(www\\.)?youtube(-nocookie)?.com/embed/([^/?#&]*).*$","i");
var oytre = new RegExp("^(https?://)(www\\.)?youtube(-nocookie)?.com/v/([^/?#&]*).*$","i");
kevincox commented 10 years ago

I'm going to close this because that is an invalid URL. If you go to that URL it 404's (and displays a blank page). Out of curiosity, do you have links to where these URLs appeared?

Closing as invalid/wontfix.

kevincox commented 10 years ago

No, it does actually work. This is one of youtube's weird flash things. I'll need to investigate further.

It appears to be related to this https://github.com/kevincox/youtube-o2i/blob/master/data/o2i.js#L23

kevincox commented 10 years ago

If you could provide an example of a webpage that does this it would be very helpful.

JLJTGR commented 10 years ago

I apologize, but the YouTube embed URL in my original post wasn't meant to be a real URL that you could click on. I replaced the video ID with 'qwertyuiop' from the top of my keyboard; which is an invalid length for a video ID.

I didn't include the in-the-wild website because the ad/sidebar content was NSFW even though the article content was. (I use Stylish to cut all of that away)

Here is the HTML copied from the page directly:

<p style="text-align: center;"><object height="383" width="472"><param name="movie" value="http://www.youtube.com/v/jcZhrsfI9Y4&amp;hl=en_US&amp;fs=1&amp;rel=0"><param name="allowFullScreen" value="true"><param name="allowscriptaccess" value="always"><embed src="http://www.youtube.com/v/jcZhrsfI9Y4&amp;hl=en_US&amp;fs=1&amp;rel=0" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" height="383" width="472"></object></p>

And the original page: (remember, NSFW)

http://www.sankakucomplex.com/2013/10/16/0-1-ton-china-quality-bridge-captured-on-film/
kevincox commented 10 years ago

lol Yeah, I noticed the video ID but then forgot to change it when I first tried to see what would happen.

I've decided to "fix" this because youtube does a similar thing when you embed a video with no parameters in the URL (see the code link above for details). I wish sites would quit using the old embed format but the world isn't a perfect place :P

kevincox commented 10 years ago

Okay, the code is in the repo and I have submitted a package to AMO for review, it should be up in a number of days.