]> cat aescling's git repositories - mastodon.git/commitdiff
Sanitize and sandbox toot embeds (#9552)
authorThibG <thib@sitedethib.com>
Sun, 23 Dec 2018 01:16:35 +0000 (02:16 +0100)
committerEugen Rochko <eugen@zeonfederated.com>
Sun, 23 Dec 2018 01:16:35 +0000 (02:16 +0100)
app/controllers/api/web/embeds_controller.rb
app/javascript/mastodon/features/ui/components/embed_modal.js

index 987290a14ce5be54b1fc3aa942598c79a34d1286..6231733b71aa101f395a7e8b80f7ea684d488b3c 100644 (file)
@@ -10,6 +10,7 @@ class Api::Web::EmbedsController < Api::Web::BaseController
     render json: status, serializer: OEmbedSerializer, width: 400
   rescue ActiveRecord::RecordNotFound
     oembed = FetchOEmbedService.new.call(params[:url])
+    oembed[:html] = Formatter.instance.sanitize(oembed[:html], Sanitize::Config::MASTODON_OEMBED) if oembed[:html].present?
 
     if oembed
       render json: oembed
index 2afb6f3d7cca132cb1f3a2b91907f1ed583eb7a7..982781db073d69319032ed809f6b01089e784c52 100644 (file)
@@ -77,6 +77,7 @@ class EmbedModal extends ImmutablePureComponent {
             className='embed-modal__iframe'
             frameBorder='0'
             ref={this.setIframeRef}
+            sandbox='allow-same-origin'
             title='preview'
           />
         </div>