agusmakmun / agusmakmun/django-markdown-editor

Youtube embed not rendering in Safari

Đang mở
#191 1 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
JavaScript
Star
901
Fork
1.3k
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

## Details
- OS (Operating System) version: macOS 12.5.1 (Monterey)
- Browser and browser version: Safari 16.0
- Django version: 4.1.2
- Martor version & theme: 1.6.14 with Bootstrap theme

### Steps to reproduce
1) **In Safari**: In the Simple Form demo, just pasting a Youtube url in the markdown editor, renders an empty iframe.
Screen Shot 2022-10-12 at 3 23 49 PM

2) As you can see, the the src parameter is set without the protocol string (https).

3) This works fine in Chrome (106.0.5249.103) and Firefox (v 105.0.3)

I know this is a bug report, but in case it helps, I made the following changes to the mdx_video.py file

1) In the extendMarkdown function, I changed the regular expression to capture the protocol along with the youtubeid parameter. So the code was change from
`r"([^(]|^)https?://www\.youtube\.com/watch\?\S*v=(?P\S[^&/]+)"`
TO
`r"([^(]|^)(?P(https?))://www\.youtube\.com/watch\?\S*v=(?P\S[^&/]+)"`

2) In the Youtube class, I changed the code from
```
class Youtube(markdown.inlinepatterns.Pattern):
def handleMatch(self, m):
if self.ext.config["youtube_nocookie"][0]:
url = "//www.youtube-nocookie.com/embed/%s" % m.group("youtubeid")
else:
url = "//www.youtube.com/embed/%s" % m.group("youtubeid")
width = self.ext.config["youtube_width"][0]
height = self.ext.config["youtube_height"][0]
return render_iframe(url, width, height)
```
TO the version below that just uses the protocol parameter
```
class Youtube(markdown.inlinepatterns.Pattern):
def handleMatch(self, m):
if self.ext.config["youtube_nocookie"][0]:
url = "{0}://www.youtube-nocookie.com/embed/{1}".format(m.group("protocol"), m.group("youtubeid"))
else:
url = "{0}://www.youtube.com/embed/{1}".format(m.group("protocol"), m.group("youtubeid"))
```

Finally, thank you so much for your work/plugin. It has been incredibly helpful. If you take pull requests, I'd be happy to make the changes for your review.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.