From: Go MAEDA Date: Tue, 30 Apr 2019 02:35:10 +0000 (+0000) Subject: Merged r18098 and r18099 from trunk to 4.0-stable (#31275). X-Git-Tag: 4.0.4~19 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=bf153760d5f2002482ae795c3f7c87d10b0212ae;p=redmine.git Merged r18098 and r18099 from trunk to 4.0-stable (#31275). git-svn-id: http://svn.redmine.org/redmine/branches/4.0-stable@18100 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index 9c0bf15ba..211cd6151 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -237,7 +237,7 @@ class AttachmentsController < ApplicationController if content_type.blank? || content_type == "application/octet-stream" content_type = Redmine::MimeType.of(attachment.filename) end - content_type.to_s + content_type.presence || "application/octet-stream" end def disposition(attachment) diff --git a/test/fixtures/attachments.yml b/test/fixtures/attachments.yml index 1b8740f49..2c83aaee3 100644 --- a/test/fixtures/attachments.yml +++ b/test/fixtures/attachments.yml @@ -268,3 +268,17 @@ attachments_020: filename: root_attachment.txt filesize: 54 author_id: 2 +attachments_022: + created_on: 2019-04-30 09:23:44 +09:00 + container_type: Project + container_id: 1 + downloads: 0 + disk_filename: 190430092344_redmine_logo.ai.unknown + disk_directory: "2019/04" + digest: 68d90c016f0806d88234a6f16530fdf0b7f1d2481354798f1a5fd165dca6b04f + id: 22 + filesize: 4994 + filename: redmine_logo.ai.unknown + author_id: 1 + description: unknown type + content_type: diff --git a/test/fixtures/files/2019/04/190430092344_redmine_logo.ai.unknown b/test/fixtures/files/2019/04/190430092344_redmine_logo.ai.unknown new file mode 100644 index 000000000..4c1c924c6 --- /dev/null +++ b/test/fixtures/files/2019/04/190430092344_redmine_logo.ai.unknown @@ -0,0 +1,232 @@ +%!PS-Adobe-3.0 +%%Creator: Adobe Fireworks +%%DocumentNeededResources: procset Adobe_level2_AI5 1.0 0 +%%+ procset Adobe_packedarray 2.0 0 +%%+ procset Adobe_cmykcolor 1.1 0 +%%+ procset Adobe_cshow 1.1 0 +%%+ procset Adobe_customcolor 1.0 0 +%%+ procset Adobe_typography_AI5 1.0 0 +%%+ procset Adobe_Illustrator_AI5 1.0 0 +%%BoundingBox:0 0 183 94 +%AI3_TemplateBox: 0 0 183 94 +%%PageOrigin:0 0 +%AI5_FileFormat 3 +%AI3_ColorUsage: Color +%%DocumentProcessColors: Cyan Magenta Yellow Black +%%EndComments +%%BeginProlog +%%EndProlog +%%BeginSetup +Adobe_packedarray /initialize get exec +Adobe_cmykcolor /initialize get exec +Adobe_cshow /initialize get exec +Adobe_customcolor /initialize get exec +Adobe_typography_AI5 /initialize get exec +Adobe_Illustrator_AI5 /initialize get exec +[ +39/quotesingle 96/grave 130/quotesinglbase 131/florin 132/quotedblbase +133/ellipsis 134/dagger 135/daggerdbl 136/circumflex 137/perthousand +139/guilsinglleft 140/OE 145/quoteleft 146/quoteright 147/quotedblleft +148/quotedblright 149/bullet 150/endash 151/emdash 152/tilde +155/guilsinglright 156/oe 157/dotlessi 159/Ydieresis 164/currency +166/brokenbar 168/dieresis 169/copyright 170/ordfeminine 172/logicalnot +174/registered 175/macron 176/ring 177/plusminus 178/twosuperior +179/threesuperior 180/acute 181/mu 183/periodcentered 184/cedilla +185/onesuperior 186/ordmasculine 188/onequarter 189/onehalf +190/threequarters 192/Agrave 193/Aacute 194/Acircumflex 195/Atilde +196/Adieresis 197/Aring 198/AE 199/Ccedilla 200/Egrave 201/Eacute +202/Ecircumflex 203/Edieresis 204/Igrave 205/Iacute 206/Icircumflex +207/Idieresis 208/Eth 209/Ntilde 210/Ograve 211/Oacute 212/Ocircumflex +213/Otilde 214/Odieresis 215/multiply 216/Oslash 217/Ugrave 218/Uacute +219/Ucircumflex 220/Udieresis 221/Yacute 222/Thorn 223/germandbls +224/agrave 225/aacute 226/acircumflex 227/atilde 228/adieresis +229/aring 230/ae 231/ccedilla 232/egrave 233/eacute 234/ecircumflex +235/edieresis 236/igrave 237/iacute 238/icircumflex 239/idieresis +240/eth 241/ntilde 242/ograve 243/oacute 244/ocircumflex 245/otilde +246/odieresis 247/divide 248/oslash 249/ugrave 250/uacute 251/ucircumflex +252/udieresis 253/yacute 254/thorn 255/ydieresis +TE +%AI3_BeginEncoding: _Delicious-Bold-Bold Delicious-Bold-Bold +[/_Delicious-Bold-Bold/Delicious-Bold-Bold 0 0 0 TZ +%AI3_EndEncoding TrueType +%%EndSetup +1 1 1 1 0 0 0 79 128 255 Lb +(Ebene 1) Ln +0.000 0.000 0.000 Xa +1 XR +44.00 44.80 m +49.60 44.80 l +50.00 49.60 l +44.80 50.80 l +44.00 44.80 l +f +0.000 0.000 0.000 Xa +1 XR +45.00 51.60 m +50.00 50.40 l +51.20 54.60 l +47.00 56.80 l +45.00 51.60 l +f +0.000 0.000 0.000 Xa +1 XR +47.40 57.60 m +51.40 55.40 l +54.60 57.60 l +51.60 61.00 l +47.40 57.60 l +f +0.000 0.000 0.000 Xa +1 XR +69.80 44.80 m +64.20 44.80 l +63.80 49.60 l +69.00 50.80 l +69.80 44.80 l +f +0.000 0.000 0.000 Xa +1 XR +68.80 51.60 m +63.80 50.40 l +62.60 54.60 l +66.80 56.80 l +68.80 51.60 l +f +0.000 0.000 0.000 Xa +1 XR +66.40 57.60 m +62.40 55.40 l +59.20 57.60 l +62.20 61.00 l +66.40 57.60 l +f +0.000 0.000 0.000 Xa +1 XR +52.60 61.60 m +55.60 58.00 l +58.40 58.00 l +61.00 61.60 l +58.40 62.40 l +55.53 62.40 l +52.60 61.60 l +f +1 To +1 0 0 1 74 43 0.000000 Tp +74.80 43.20 m +141.58 43.20 l +141.58 34.56 l +74.80 34.56 l +74.80 43.20 l +n +TP +0 -14.00 Td +0.200 0.200 0.200 Xa +/_Delicious-Bold-Bold 14.00 Tf +0.000000 Ts +100.000000 100.0 Tz +1 0 Tk +0.000000 Tt +0 Ta +0.200 0.200 0.200 Xa +0 Tr +(Flexible Project Management) Tj +TO +1 To +1 0 0 1 74 60 0.000000 Tp +74.00 60.00 m +139.29 60.00 l +139.29 36.48 l +74.00 36.48 l +74.00 60.00 l +n +TP +0 -45.00 Td +0.604 0.027 0.000 Xa +/_Delicious-Bold-Bold 45.00 Tf +0.000000 Ts +100.000000 100.0 Tz +1 0 Tk +0.000000 Tt +0 Ta +0.604 0.027 0.000 Xa +0 Tr +(RED) Tj +/_Delicious-Bold-Bold 45.00 Tf +0.000000 Ts +100.000000 100.0 Tz +1 0 Tk +0.000000 Tt +0 Ta +0.753 0.106 0.102 Xa +0 Tr +(MINE) Tj +TO +0.604 0.027 0.000 Xa +1 XR +44.00 44.80 m +49.60 44.80 l +50.00 49.60 l +44.80 50.80 l +44.00 44.80 l +f +0.706 0.055 0.059 Xa +1 XR +45.00 51.60 m +50.00 50.40 l +51.20 54.60 l +47.00 56.80 l +45.00 51.60 l +f +0.753 0.106 0.102 Xa +1 XR +47.40 57.60 m +51.40 55.40 l +54.60 57.60 l +51.60 61.00 l +47.40 57.60 l +f +0.604 0.027 0.000 Xa +1 XR +69.80 44.80 m +64.20 44.80 l +63.80 49.60 l +69.00 50.80 l +69.80 44.80 l +f +0.706 0.055 0.059 Xa +1 XR +68.80 51.60 m +63.80 50.40 l +62.60 54.60 l +66.80 56.80 l +68.80 51.60 l +f +0.753 0.106 0.102 Xa +1 XR +66.40 57.60 m +62.40 55.40 l +59.20 57.60 l +62.20 61.00 l +66.40 57.60 l +f +0.753 0.106 0.102 Xa +1 XR +52.60 61.60 m +55.60 58.00 l +58.40 58.00 l +61.00 61.60 l +58.40 62.40 l +55.53 62.40 l +52.60 61.60 l +f +LB +%%PageTrailer +gsave annotatepage grestore showpage +%%Trailer +Adobe_Illustrator_AI5 /terminate get exec +Adobe_typography_AI5 /terminate get exec +Adobe_customcolor /terminate get exec +Adobe_cshow /terminate get exec +Adobe_cmykcolor /terminate get exec +Adobe_packedarray /terminate get exec +%%EOF diff --git a/test/functional/attachments_controller_test.rb b/test/functional/attachments_controller_test.rb index a5d4c1705..e75b1f32b 100644 --- a/test/functional/attachments_controller_test.rb +++ b/test/functional/attachments_controller_test.rb @@ -360,6 +360,16 @@ class AttachmentsControllerTest < Redmine::ControllerTest set_tmp_attachments_directory end + def test_download_should_assign_application_octet_stream_if_content_type_is_not_determined + get :download, :params => { + :id => 22 + } + assert_response :success + assert_nil Redmine::MimeType.of(attachments(:attachments_022).filename) + assert_equal 'application/octet-stream', @response.content_type + set_tmp_attachments_directory + end + def test_download_missing_file get :download, :params => { :id => 2