Skip to content

Commit 94f2558

Browse files
Restore inadvertently-removed fallback
1 parent 3900975 commit 94f2558

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

activestorage/app/controllers/active_storage/disk_controller.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,11 @@ def update
1919
if token = decode_verified_token
2020
if acceptable_content?(token)
2121
disk_service.upload token[:key], request.body, checksum: token[:checksum]
22-
head :no_content
2322
else
2423
head :unprocessable_entity
2524
end
25+
else
26+
head :not_found
2627
end
2728
rescue ActiveStorage::IntegrityError
2829
head :unprocessable_entity

activestorage/test/controllers/disk_controller_test.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,10 @@ class ActiveStorage::DiskControllerTest < ActionDispatch::IntegrationTest
6767
assert_response :unprocessable_entity
6868
assert_not blob.service.exist?(blob.key)
6969
end
70+
71+
test "directly uploading blob with invalid token" do
72+
put update_rails_disk_service_url(encoded_token: "invalid"),
73+
params: "Something else entirely!", headers: { "Content-Type" => "text/plain" }
74+
assert_response :not_found
75+
end
7076
end

0 commit comments

Comments
 (0)