From 45221e653d0d40eb582500cf157d0df6666c3ec9 Mon Sep 17 00:00:00 2001 From: Daniel Nitsikopoulos Date: Sat, 24 Feb 2024 16:07:45 +1100 Subject: [PATCH] Return 400 when update request is invalid --- slices/micropub/actions/posts/handle.rb | 2 ++ slices/micropub/commands/posts/update.rb | 2 ++ 2 files changed, 4 insertions(+) diff --git a/slices/micropub/actions/posts/handle.rb b/slices/micropub/actions/posts/handle.rb index 31316de..22d495f 100644 --- a/slices/micropub/actions/posts/handle.rb +++ b/slices/micropub/actions/posts/handle.rb @@ -26,6 +26,8 @@ module Micropub res.status = 200 in Failure[:not_permitted] halt 401 + in Failure[:invalid_request] + halt 400 end end diff --git a/slices/micropub/commands/posts/update.rb b/slices/micropub/commands/posts/update.rb index 2e06343..252be65 100644 --- a/slices/micropub/commands/posts/update.rb +++ b/slices/micropub/commands/posts/update.rb @@ -13,6 +13,8 @@ module Micropub post = post_repo.fetch!(slug) if params.key? :replace + return Failure(:invalid_request) 400 unless params[:replace].is_a?(Hash) + content = params[:replace].delete(:content) content = content.is_a?(Array) ? content.first : content name = params[:replace].delete(:name)