Project

General

Profile

Patch #42394 » 0001-force-format-to-html-for-the-download_named_attachme.patch

Jens Krämer, 2025-03-11 07:36

View differences:

config/routes.rb
316 316

  
317 317
  # additional routes for having the file name at the end of url
318 318
  get 'attachments/:id/:filename', :to => 'attachments#show', :id => /\d+/, :filename => /.*/, :as => 'named_attachment', :format => 'html'
319
  get 'attachments/download/:id/:filename', :to => 'attachments#download', :id => /\d+/, :filename => /.*/, :as => 'download_named_attachment'
319
  get 'attachments/download/:id/:filename', :to => 'attachments#download', :id => /\d+/, :filename => /.*/, :as => 'download_named_attachment', format: 'html'
320 320
  get 'attachments/download/:id', :to => 'attachments#download', :id => /\d+/
321 321
  get 'attachments/thumbnail/:id(/:size)', :to => 'attachments#thumbnail', :id => /\d+/, :size => /\d+/, :as => 'thumbnail'
322 322
  resources :attachments, :only => [:show, :update, :destroy]
test/integration/attachments_test.rb
267 267
    end
268 268
  end
269 269

  
270
  def test_unauthorized_named_download_link_should_redirect_to_login
271
    with_settings login_required: '1' do
272
      get "/attachments/download/1"
273
      assert_redirected_to "/login?back_url=http%3A%2F%2Fwww.example.com%2Fattachments%2Fdownload%2F1"
274

  
275
      get "/attachments/download/1/error281.txt"
276
      assert_redirected_to "/login?back_url=http%3A%2F%2Fwww.example.com%2Fattachments%2Fdownload%2F1%2Ferror281.txt"
277
    end
278
  end
279

  
270 280
  private
271 281

  
272 282
  def ajax_upload(filename, content, attachment_id=1)
    (1-1/1)