Defect #42839 » 42839-v2.patch
app/controllers/repositories_controller.rb | ||
---|---|---|
160 | 160 |
# Force the download |
161 | 161 |
send_opt = {:filename => filename_for_content_disposition(@path.split('/').last)} |
162 | 162 |
send_type = Redmine::MimeType.of(@path) |
163 |
send_opt[:type] = send_type.to_s if send_type |
|
163 |
case send_type |
|
164 |
when nil |
|
165 |
# No MIME type detected. Let Rails use the default type. |
|
166 |
when 'application/javascript' |
|
167 |
# Avoid ActionController::InvalidCrossOriginRequest exception by setting non-JS content type |
|
168 |
send_opt[:type] = 'text/plain' |
|
169 |
else |
|
170 |
send_opt[:type] = send_type |
|
171 |
end |
|
164 | 172 |
send_opt[:disposition] = disposition(@path) |
165 | 173 |
send_data @repository.cat(@path, @rev), send_opt |
166 | 174 |
else |
test/functional/repositories_subversion_controller_test.rb | ||
---|---|---|
358 | 358 |
assert_equal "attachment; filename=\"helloworld.c\"; filename*=UTF-8''helloworld.c", @response.headers['Content-Disposition'] |
359 | 359 |
end |
360 | 360 | |
361 |
def test_entry_should_return_text_plain_for_js_files |
|
362 |
# JavaScript files should be served as 'text/plain' instead of |
|
363 |
# 'application/javascript' to avoid |
|
364 |
# ActionController::InvalidCrossOriginRequest exception |
|
365 |
assert_equal 0, @repository.changesets.count |
|
366 |
@repository.fetch_changesets |
|
367 |
@project.reload |
|
368 |
assert_equal NUM_REV, @repository.changesets.count |
|
369 |
get( |
|
370 |
:raw, |
|
371 |
:params => { |
|
372 |
:id => PRJ_ID, |
|
373 |
:repository_id => @repository.id, |
|
374 |
:path => repository_path_hash(['subversion_test', 'foo.js'])[:param] |
|
375 |
} |
|
376 |
) |
|
377 |
assert_response :success |
|
378 |
assert_equal 'text/plain', @response.media_type |
|
379 |
assert_match /attachment/, @response.headers['Content-Disposition'] |
|
380 |
end |
|
381 | ||
361 | 382 |
def test_directory_entry |
362 | 383 |
assert_equal 0, @repository.changesets.count |
363 | 384 |
@repository.fetch_changesets |
- « Previous
- 1
- 2
- 3
- Next »