diff --git a/lib/discourse_activity_pub/json_ld.rb b/lib/discourse_activity_pub/json_ld.rb index d4dea7a7..e326e6e0 100644 --- a/lib/discourse_activity_pub/json_ld.rb +++ b/lib/discourse_activity_pub/json_ld.rb @@ -75,6 +75,7 @@ def valid_content_type?(value) end def valid_accept?(value) + return false if value.blank? value.split(",").compact.collect(&:strip).all? { |v| valid_content_type?(v) } end diff --git a/spec/lib/discourse_activity_pub/json_ld_spec.rb b/spec/lib/discourse_activity_pub/json_ld_spec.rb index 8d5a39f7..99f1e50e 100644 --- a/spec/lib/discourse_activity_pub/json_ld_spec.rb +++ b/spec/lib/discourse_activity_pub/json_ld_spec.rb @@ -45,6 +45,10 @@ false, ) end + + it "does not validate empty accept headers" do + expect(described_class.valid_accept?(nil)).to eq(false) + end end describe "#address_json" do