Skip to content

Commit e10c918

Browse files
feat(application_html_formatters_helper): whitelist only YouTube URLs
We do this because from the business logic point-of-view, Coursemology only supports YouTube. The New Video form's placeholder specifies that, and the production database only has YouTube URLs.
1 parent 08b9e83 commit e10c918

File tree

2 files changed

+8
-14
lines changed

2 files changed

+8
-14
lines changed

app/helpers/application_html_formatters_helper.rb

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,7 @@ def self.build_html_pipeline(custom_options)
8686
# List of video hosting site URLs to allow
8787
VIDEO_URL_WHITELIST = Regexp.union(
8888
/\A(?:https?:)?\/\/(?:www\.)?(?:m.)?youtube\.com\//,
89-
/\A(?:https?:)?\/\/(?:www\.)?youtu.be\//,
90-
/\A(?:https?:)?\/\/(?:www\.)?(?:player.)?vimeo\.com\//,
91-
/\A(?:https?:)?\/\/(?:www\.)?vine\.co\//,
92-
/\A(?:https?:)?\/\/(?:www\.)?instagram\.com\//,
93-
/\A(?:https?:)?\/\/(?:www\.)?(?:geo.)?dailymotion\.com\//,
94-
/\A(?:https?:)?\/\/(?:www\.)?dai\.ly\//,
95-
/\A(?:https?:)?\/\/(?:www\.)?youku\.com\//
89+
/\A(?:https?:)?\/\/(?:www\.)?youtu.be\//
9690
).freeze
9791

9892
OEMBED_WHITELIST_TRANSFORMER = lambda do |env|

spec/helpers/application_formatters_helper_spec.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,6 @@ def hello:
9494
it 'does not remove embedded content from allowed sources' do
9595
html = <<-HTML
9696
<iframe src="//youtube.com/video1"></iframe>
97-
<iframe src="//instagram.com/video2"></iframe>
98-
<iframe src="//vimeo.com/video3"></iframe>
99-
<iframe src="//vine.co/video4"></iframe>
100-
<iframe src="//dailymotion.com/video5"></iframe>
101-
<iframe src="//youku.com/video6"></iframe>
10297
HTML
10398
expect(helper.format_html(html)).to eq(html)
10499
end
@@ -111,6 +106,11 @@ def hello:
111106
<iframe src="//vine.com"></iframe>
112107
<iframe src="//dailymotion.co"></iframe>
113108
<iframe src="//vimeo.org"></iframe>
109+
<iframe src="//instagram.com/video2"></iframe>
110+
<iframe src="//vimeo.com/video3"></iframe>
111+
<iframe src="//vine.co/video4"></iframe>
112+
<iframe src="//dailymotion.com/video5"></iframe>
113+
<iframe src="//youku.com/video6"></iframe>
114114
HTML
115115
expect(helper.format_html(html)).not_to include('iframe')
116116
end
@@ -141,7 +141,7 @@ def hello:
141141
expect(result.scan('src="https://www.youtube.com/embed/jNQXAC9IVRw').size).to eq(embed_count)
142142
end
143143

144-
it 'transforms embedded content from dailymotion' do
144+
xit 'transforms embedded content from dailymotion' do
145145
html = <<-HTML
146146
<oembed url="https://www.dailymotion.com/video/x3k7o56"></oembed>
147147
<oembed url="https://dailymotion.com/video/x3k7o56"></oembed>
@@ -158,7 +158,7 @@ def hello:
158158
expect(result.scan('src="https://geo.dailymotion.com/player.html?video=x3k7o56').size).to eq(embed_count)
159159
end
160160

161-
it 'transforms embedded content from vimeo' do
161+
xit 'transforms embedded content from vimeo' do
162162
html = <<-HTML
163163
<oembed url="https://vimeo.com/channels/staffpicks/852794606"></oembed>
164164
<oembed url="https://vimeo.com/852794606"></oembed>

0 commit comments

Comments
 (0)