diff options
author | Go MAEDA <maeda@farend.jp> | 2021-04-16 01:36:59 +0000 |
---|---|---|
committer | Go MAEDA <maeda@farend.jp> | 2021-04-16 01:36:59 +0000 |
commit | e41cf61de80bb183abeae8c1674cb7d0ef9d1277 (patch) | |
tree | 7048ac258cd3c7990c8b541f72a3efd600807e94 /test/unit/attachment_test.rb | |
parent | 2027b8750aa8f6432cf58fc5b0f8bf15ef8a03d8 (diff) | |
download | redmine-e41cf61de80bb183abeae8c1674cb7d0ef9d1277.tar.gz redmine-e41cf61de80bb183abeae8c1674cb7d0ef9d1277.zip |
Validate attachment filenames on every change (#34367).
Patch by Holger Just.
git-svn-id: http://svn.redmine.org/redmine/trunk@20946 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/unit/attachment_test.rb')
-rw-r--r-- | test/unit/attachment_test.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/test/unit/attachment_test.rb b/test/unit/attachment_test.rb index 5aa5220a9..9484c9360 100644 --- a/test/unit/attachment_test.rb +++ b/test/unit/attachment_test.rb @@ -152,6 +152,19 @@ class AttachmentTest < ActiveSupport::TestCase end end + def test_extension_update_should_be_validated_against_denied_extensions + with_settings :attachment_extensions_denied => "txt, png" do + a = Attachment.new(:container => Issue.find(1), + :file => mock_file_with_options(:original_filename => "test.jpeg"), + :author => User.find(1)) + assert_save a + + b = Attachment.find(a.id) + b.filename = "test.png" + assert !b.save + end + end + def test_valid_extension_should_be_case_insensitive with_settings :attachment_extensions_allowed => "txt, Png" do assert Attachment.valid_extension?(".pnG") |