diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2020-02-07 15:24:22 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-07 15:24:22 +0100 |
commit | a64973aecff0595bd34a6e70393d471b8dbf1841 (patch) | |
tree | a9ecb615cf0310cab7b48360ff8edd71562a4979 /app/controllers | |
parent | 02236332bab7c5cc4ddf4a3a778fd956f6851322 (diff) |
Fix malformed HTML causing uncaught error (#13042)
Fix OEmbed preview API leaking existence of private statuses (see #12930)
Diffstat (limited to 'app/controllers')
-rw-r--r-- | app/controllers/api/web/embeds_controller.rb | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/app/controllers/api/web/embeds_controller.rb b/app/controllers/api/web/embeds_controller.rb index 6231733b7..4aa31695c 100644 --- a/app/controllers/api/web/embeds_controller.rb +++ b/app/controllers/api/web/embeds_controller.rb @@ -7,15 +7,21 @@ class Api::Web::EmbedsController < Api::Web::BaseController def create status = StatusFinder.new(params[:url]).status + + return not_found if status.hidden? + 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 - else - render json: {}, status: :not_found + return not_found if oembed.nil? + + begin + oembed[:html] = Formatter.instance.sanitize(oembed[:html], Sanitize::Config::MASTODON_OEMBED) + rescue ArgumentError + return not_found end + + render json: oembed end end |