Feature #32085 » 32085-allow-newline-as-separator-v3.patch
| app/models/attachment.rb | ||
|---|---|---|
| 445 | 445 |
extension = extension.downcase.sub(/\A\.+/, '') |
| 446 | 446 | |
| 447 | 447 |
unless extensions.is_a?(Array) |
| 448 |
extensions = extensions.to_s.split(",").map(&:strip)
|
|
| 448 |
extensions = extensions.to_s.split(/[\s,]+/)
|
|
| 449 | 449 |
end |
| 450 | 450 |
extensions = extensions.map {|s| s.downcase.sub(/\A\.+/, '')}.reject(&:blank?)
|
| 451 | 451 |
extensions.include?(extension) |
| app/models/mail_handler.rb | ||
|---|---|---|
| 308 | 308 | |
| 309 | 309 |
# Returns false if the +attachment+ of the incoming email should be ignored |
| 310 | 310 |
def accept_attachment?(attachment) |
| 311 |
@excluded ||= Setting.mail_handler_excluded_filenames.to_s.split(',').map(&:strip).reject(&:blank?)
|
|
| 311 |
@excluded ||= Setting.mail_handler_excluded_filenames.to_s.split(/[\s,]+/).reject(&:blank?)
|
|
| 312 | 312 |
@excluded.each do |pattern| |
| 313 | 313 |
if Setting.mail_handler_enable_regex_excluded_filenames? |
| 314 | 314 |
regexp = %r{\A#{pattern}\z}i
|
| test/unit/attachment_test.rb | ||
|---|---|---|
| 139 | 139 |
end |
| 140 | 140 | |
| 141 | 141 |
def test_extension_should_be_validated_against_denied_extensions |
| 142 |
with_settings :attachment_extensions_denied => "txt, png" do |
|
| 142 |
with_settings :attachment_extensions_denied => "txt, png\r\ncsv" do
|
|
| 143 | 143 |
a = Attachment.new(:container => Issue.find(1), |
| 144 | 144 |
:file => mock_file_with_options(:original_filename => "test.jpeg"), |
| 145 | 145 |
:author => User.find(1)) |
| ... | ... | |
| 153 | 153 |
end |
| 154 | 154 | |
| 155 | 155 |
def test_valid_extension_should_be_case_insensitive |
| 156 |
with_settings :attachment_extensions_allowed => "txt, Png" do |
|
| 156 |
with_settings :attachment_extensions_allowed => "txt, Png\r\ncsv" do
|
|
| 157 | 157 |
assert Attachment.valid_extension?(".pnG")
|
| 158 | 158 |
assert !Attachment.valid_extension?(".jpeg")
|
| 159 | 159 |
end |
| 160 |
with_settings :attachment_extensions_denied => "txt, Png" do |
|
| 160 |
with_settings :attachment_extensions_denied => "txt, Png\r\ncsv" do
|
|
| 161 | 161 |
assert !Attachment.valid_extension?(".pnG")
|
| 162 | 162 |
assert Attachment.valid_extension?(".jpeg")
|
| 163 | 163 |
end |
| test/unit/mail_handler_test.rb | ||
|---|---|---|
| 1157 | 1157 |
end |
| 1158 | 1158 | |
| 1159 | 1159 |
def test_attachments_that_match_mail_handler_excluded_filenames_should_be_ignored |
| 1160 |
with_settings :mail_handler_excluded_filenames => "*.vcf,\n *.jpg" do |
|
| 1160 |
with_settings :mail_handler_excluded_filenames => "*.vcf,\n *.jpg\r\n*.csv" do
|
|
| 1161 | 1161 |
issue = submit_email('ticket_with_attachment.eml', :issue => {:project => 'onlinestore'})
|
| 1162 | 1162 |
assert issue.is_a?(Issue) |
| 1163 | 1163 |
assert !issue.new_record? |
| ... | ... | |
| 1166 | 1166 |
end |
| 1167 | 1167 | |
| 1168 | 1168 |
def test_attachments_that_match_mail_handler_excluded_filenames_by_regex_should_be_ignored |
| 1169 |
with_settings :mail_handler_excluded_filenames => '.+\.vcf,(pa|nut)ella\.jpg',
|
|
| 1169 |
with_settings :mail_handler_excluded_filenames => ".+\\.vcf,(pa|nut)ella\\.jpg\r\n.+\\.csv",
|
|
| 1170 | 1170 |
:mail_handler_enable_regex_excluded_filenames => 1 do |
| 1171 | 1171 |
issue = submit_email('ticket_with_attachment.eml', :issue => {:project => 'onlinestore'})
|
| 1172 | 1172 |
assert issue.is_a?(Issue) |
- « Previous
- 1
- 2
- 3
- Next »