Project

General

Profile

Defect #44335 » 0001-Stop-treating-Adobe-Illustrator-files-as-PDF-files-w.patch

Go MAEDA, 2026-08-15 10:46

View differences:

app/controllers/attachments_controller.rb
"application/octet-stream"
end
if is_thumb && content_type == "application/pdf"
# PDF previews are stored in PNG format
if is_thumb && !content_type.start_with?("image/")
# Thumbnails of non-image files are stored in PNG format
content_type = "image/png"
end
app/models/attachment.rb
def thumbnailable?
Redmine::Thumbnail.convert_available? && (
image? || (is_pdf? && Redmine::Thumbnail.gs_available?)
image? ||
(Redmine::Thumbnail.gs_available? &&
# Illustrator files are often PDF compatible
['application/pdf', 'application/illustrator'].include?(Redmine::MimeType.of(filename)))
)
end
lib/redmine/mime_type.rb
'image/tiff' => 'tiff,tif',
'image/webp' => 'webp',
'image/x-ms-bmp' => 'bmp',
# Not registered with IANA, but matches Marcel's type for .ai
'application/illustrator' => 'ai',
'application/javascript' => 'js',
'application/pdf' => 'pdf',
'video/mp4' => 'mp4',
test/unit/attachment_test.rb
assert_equal false, Attachment.new(:filename => 'test.txt').thumbnailable?
end
def test_thumbnailable_should_be_true_for_illustrator_files
Redmine::Thumbnail.stubs(:convert_available?).returns(true)
Redmine::Thumbnail.stubs(:gs_available?).returns(true)
assert_equal true, Attachment.new(:filename => 'test.ai').thumbnailable?
end
def test_markdownized_previewable_should_be_true_for_supported_extensions
skip unless Redmine::Markdownizer.available?
......
assert_equal expected, attachment.is_text?, attachment.inspect
end
end
def test_is_pdf
to_test = {
'report.pdf' => true,
# Illustrator files are not PDF files, even though some of them are
# PDF compatible
'logo.ai' => false,
}
to_test.each do |filename, expected|
assert_equal expected, Attachment.new(:filename => filename).is_pdf?, filename
end
end
end
(2-2/2)