File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11# Changelog
22
3+ ## [ 0.21.1] - 2025-10-04
4+
5+ ### Fixed
6+
7+ - Fix improper handling of optional file uploads ([ #595 ] ) (George Dietrich) <!-- blacksmoke16 -->
8+
9+ [ 0.21.1 ] : https://github.com/athena-framework/framework/releases/tag/v0.21.1
10+ [ #595 ] : https://github.com/athena-framework/athena/pull/595
11+
312## [ 0.21.0] - 2025-09-04
413
514### Changed
Original file line number Diff line number Diff line change 11name : athena
22
3- version : 0.21.0
3+ version : 0.21.1
44
55crystal : ~> 1.14
66
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ struct FileParserTest < ASPEC::TestCase
88 request = new_request(
99 body: String .build do |io |
1010 HTTP ::FormData .build io, " boundary" do |form |
11+ # Non HTML file input types have a `nil` filename.
1112 form.field(" age" , 12 )
1213 form.file(
1314 " success" ,
@@ -20,6 +21,18 @@ struct FileParserTest < ASPEC::TestCase
2021 }
2122 )
2223
24+ # Skipped because optional HTML file input types have a `""` filename if no file was selected.
25+ form.file(
26+ " optional" ,
27+ IO ::Memory .new,
28+ HTTP ::FormData ::FileMetadata .new(
29+ " "
30+ ),
31+ headers: HTTP ::Headers {
32+ " content-type" => " text/plain" ,
33+ }
34+ )
35+
2336 form.file(
2437 " too_big" ,
2538 File .open(" #{ __DIR__ } /assets/file-big.txt" ),
@@ -75,6 +88,7 @@ struct FileParserTest < ASPEC::TestCase
7588 file_parser.uploaded_file?(file2 .path).should be_false
7689
7790 request.attributes.get(" age" , String ).should eq " 12"
91+ request.attributes.has?(" optional" ).should be_false
7892
7993 file_parser.clear
8094
Original file line number Diff line number Diff line change @@ -62,7 +62,7 @@ alias ATHA = ATH::Annotations
6262alias ATHR = ATH ::Controller ::ValueResolvers
6363
6464module Athena::Framework
65- VERSION = " 0.21.0 "
65+ VERSION = " 0.21.1 "
6666
6767 # The name of the environment variable used to determine Athena's current environment.
6868 ENV_NAME = " ATHENA_ENV"
Original file line number Diff line number Diff line change @@ -21,7 +21,9 @@ class Athena::Framework::FileParser
2121 uploaded_file_count = 0
2222
2323 HTTP ::FormData .parse(request.request) do |part |
24- unless filename = part.filename.presence
24+ case filename = part.filename
25+ when " " then next
26+ when .nil?
2527 request.attributes.set part.name, part.body.gets_to_end, String
2628 next
2729 end
You can’t perform that action at this time.
0 commit comments