Skip to content

Commit

Permalink
Merge pull request #17245 from opf/fix/treat-html-non-inline
Browse files Browse the repository at this point in the history
Do not treat HTML as inlinable
  • Loading branch information
oliverguenther authored Nov 21, 2024
2 parents 037c6cc + df6600d commit 568d468
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
6 changes: 5 additions & 1 deletion app/models/attachment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,12 @@ def is_pdf?
content_type == "application/pdf"
end

def is_html?
content_type == "text/html"
end

def is_text?
content_type.match?(/\Atext\/.+/)
content_type.match?(/\Atext\/.+/) && !is_html?
end

def is_diff?
Expand Down
11 changes: 11 additions & 0 deletions spec/models/attachment_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,17 @@
end
end

describe "for an HTML file" do
let(:attachment) { described_class.new }

it "assumes it not to be inlineable" do
attachment.content_type = "text/html"
expect(attachment).to be_is_html
expect(attachment).not_to be_is_text
expect(attachment).not_to be_inlineable
end
end

describe "for a binary file" do
before { binary_attachment.save! }

Expand Down

0 comments on commit 568d468

Please sign in to comment.