discourse/lib/onebox/engine/loom_onebox.rb
Blake Erickson 17116c440b
SECURITY: Restrict allowed URL patterns
Restrict allowed URL patterns for oneboxes.
2025-02-04 13:32:34 -03:00

39 lines
831 B
Ruby

# frozen_string_literal: true
module Onebox
module Engine
class LoomOnebox
include Engine
include StandardEmbed
matches_domain("loom.com", "www.loom.com")
always_https
requires_iframe_origins "https://www.loom.com"
def self.matches_path(path)
path.match?(%r{^/share/\w+(/\w+)?/?$})
end
def placeholder_html
::Onebox::Helpers.video_placeholder_html
end
def to_html
video_id = url.split("/").last
video_src = "https://www.loom.com/embed/#{video_id}"
<<~HTML
<iframe
class="loom-onebox"
src="#{video_src}"
frameborder="0"
webkitallowfullscreen
mozallowfullscreen
allowfullscreen
</iframe>
HTML
end
end
end
end