From 4583c576f63c8a27a3c72a6045fd1d1f215810f7 Mon Sep 17 00:00:00 2001 From: Quinton Miller Date: Sat, 25 Nov 2023 01:30:45 +0800 Subject: [PATCH] simplify --- src/http/formdata.cr | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/http/formdata.cr b/src/http/formdata.cr index eebc307865e0..c444863ff82b 100644 --- a/src/http/formdata.cr +++ b/src/http/formdata.cr @@ -138,15 +138,11 @@ module HTTP::FormData size = nil name = nil - first = true - content_disposition.split(';') do |part| - if first - first = false - raise Error.new("Invalid Content-Disposition: not form-data") unless part == "form-data" - next - end - - key, _, value = part.partition('=') + parts = content_disposition.split(';') + type = parts.shift? + raise Error.new("Invalid Content-Disposition: not form-data") unless type == "form-data" + parts.each do |part| + key, value = part.split('=', 2) key = key.strip value = value.strip if value[0] == '"'