Project

General

Profile

Feature #43484 » 0002-Stop-using-legacy-image-x-ms-bmp-MIME-type-for-BMP-f.patch

Go MAEDA, 2026-03-04 10:03

View differences:

lib/redmine/mime_type.rb
44 44
      'image/png' => 'png',
45 45
      'image/tiff' => 'tiff,tif',
46 46
      'image/webp' => 'webp',
47
      'image/x-ms-bmp' => 'bmp',
48 47
      'application/javascript' => 'js',
49 48
      'application/pdf' => 'pdf',
50 49
      'video/mp4' => 'mp4',
test/helpers/application_helper_test.rb
200 200
    end
201 201
  end
202 202

  
203
  def test_attached_images_filename_extension
204
    a1 =
205
      Attachment.new(
206
        :container => Issue.find(1),
207
        :file => mock_file_with_options({:original_filename => "testtest.JPG"}),
208
        :author => User.find(1)
209
      )
210
    assert a1.save
211
    assert_equal "testtest.JPG", a1.filename
212
    assert_equal "image/jpeg", a1.content_type
213
    assert a1.image?
214

  
215
    a2 =
216
      Attachment.new(
217
        :container => Issue.find(1),
218
        :file => mock_file_with_options({:original_filename => "testtest.jpeg"}),
219
        :author => User.find(1)
220
      )
221
    assert a2.save
222
    assert_equal "testtest.jpeg", a2.filename
223
    assert_equal "image/jpeg", a2.content_type
224
    assert a2.image?
225

  
226
    a3 =
227
      Attachment.new(
228
        :container => Issue.find(1),
229
        :file => mock_file_with_options({:original_filename => "testtest.JPE"}),
230
        :author => User.find(1)
231
      )
232
    assert a3.save
233
    assert_equal "testtest.JPE", a3.filename
234
    assert_equal "image/jpeg", a3.content_type
235
    assert a3.image?
236

  
237
    a4 =
238
      Attachment.new(
239
        :container => Issue.find(1),
240
        :file => mock_file_with_options({:original_filename => "Testtest.BMP"}),
241
        :author => User.find(1)
242
      )
243
    assert a4.save
244
    assert_equal "Testtest.BMP", a4.filename
245
    assert_equal "image/bmp", a4.content_type
246
    assert a4.image?
247

  
248
    to_test = {
249
      'Inline image: !testtest.jpg!' =>
250
        'Inline image: <img src="/attachments/download/' + a1.id.to_s + '/testtest.JPG" alt="" loading="lazy">',
251
      'Inline image: !testtest.jpeg!' =>
252
        'Inline image: <img src="/attachments/download/' + a2.id.to_s + '/testtest.jpeg" alt="" loading="lazy">',
253
      'Inline image: !testtest.jpe!' =>
254
        'Inline image: <img src="/attachments/download/' + a3.id.to_s + '/testtest.JPE" alt="" loading="lazy">',
255
      'Inline image: !testtest.bmp!' =>
256
        'Inline image: <img src="/attachments/download/' + a4.id.to_s + '/Testtest.BMP" alt="" loading="lazy">',
257
    }
258

  
259
    attachments = [a1, a2, a3, a4]
260
    with_settings :text_formatting => 'textile' do
261
      to_test.each {|text, result| assert_equal "<p>#{result}</p>", textilizable(text, :attachments => attachments)}
262
    end
263
  end
264

  
203 265
  def test_textile_external_links
204 266
    to_test = {
205 267
      'This is a "link":http://foo.bar' => 'This is a <a href="http://foo.bar" class="external">link</a>',
(2-2/4)