-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Youtube iframe 'src' parameter stripped out after saving an entry #278
Comments
Also, I think those |
@andris-sevcenko just checking in to see if you have seen this issue. Thank you. |
@sidm1983 I have. Are you willing to submit a PR for this? |
Just released 2.8.3 which fixes this. |
Just updated the default HTML Purifier config for new Craft projects as well. You will need to make this change manually if you have a |
Thanks for that @andris-sevcenko & @brandonkelly. Apologies I didn't submit a PR for this, as I didn't get a chance at the time. Thanks for sorting it out though. @brandonkelly, quick question about the change you made in the above commit. It looks like the dot characters are not being escaped, which means they will match any character and not just a single dot. Is this intentional? |
@brandonkelly just wanted to check if you've seen my comment above about escaping the dot character in the regex. Thank you. 😊🙏🏽 |
Description
So I was just testing the default HTML Purifier config that now allows embedding of youtube videos properly and doesn't strip it out on saving of an entry, however it is still not working properly. I believe this is because the regex used to determine whether the iframe src URL is either youtube or vimeo is not quite right and doesn't account for an edge case in youtube urls that omit the
https:
part at the beginning of the URL.Steps to reproduce
Solution
This is happening because when you first embed the youtube video, the resulting HTML looks like this:
As you can see above, the
src
parameter starts with//
, instead ofhttps://
As a result, the above
src
value gets stripped out because the current regex being used doesn't account for the possibility of a missing scheme:redactor/src/Field.php
Line 1019 in 2fff517
Here is a regex I've used in the past that works with this edge case:
Please note the additional brackets and question mark around the
https?:
part marking it as optional. It also accounts for youtube's nocookie URLs. Lastly, the.
(dot) characters have also been escaped as we want it to match an actual dot and not just any character.Additional info
The text was updated successfully, but these errors were encountered: