Hi,

after my freedombox upgraded from stretch to buster, I've noticed that
I can't use coquelicot to share files any more.

Here is patch, that at least makes coquelicot usable on buster.

It's available on salsa as well, if it's more convenient to take.
https://salsa.debian.org/skv-guest/coquelicot

Tags: patch

-- 
Best regards,
Andrey Skvortsov
From b2a2081137b8bae17f9c86554af132e85dec569f Mon Sep 17 00:00:00 2001
From: Andrey Skvortsov <andrej.skvort...@gmail.com>
Date: Mon, 22 Jul 2019 22:48:19 +0300
Subject: [PATCH] fix upload functionality with rack 2.x

because of changes in rack 2.x upload functionality in coquelicot was broken.
See https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=923307

First by default rack requires rewindable input stream.
Coquelicot tried to avoid rewindable streams for performance and
security reasons. See HACKING for more details.
This change enables usage of rewindable streams to make rack
happy again.

Because of changes in rack API following build error was fixed as well:

Coquelicot::Rack::Upload#call when called for POST /upload when no file has been submitted should set X_COQUELICOT_FORWARD in env
Failure/Error: @params = Rack::Utils::KeySpaceConstrainedParams.new

ArgumentError:
 wrong number of arguments (given 0, expected 1)
 # ./lib/coquelicot/rack/multipart_parser.rb:26:in `new'
 # ./lib/coquelicot/rack/multipart_parser.rb:26:in `initialize'
 ...
 # ./spec/coquelicot/rack/upload_spec.rb:291:in `block (5 levels) in <module:Rack>'
 # ./spec/spec_helper.rb:49:in `block (2 levels) in <top (required)>'

Signed-off-by: Andrey Skvortsov <andrej.skvort...@gmail.com>
---
 lib/coquelicot/app.rb                   | 2 +-
 lib/coquelicot/rack/multipart_parser.rb | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/coquelicot/app.rb b/lib/coquelicot/app.rb
index c9c7ed3..7a12b40 100644
--- a/lib/coquelicot/app.rb
+++ b/lib/coquelicot/app.rb
@@ -143,7 +143,7 @@ module Coquelicot
         :pid => settings.pid,
         :listeners => settings.listen,
         :use => :ThreadSpawn,
-        :rewindable_input => false,
+        :rewindable_input => true,
         :client_max_body_size => nil
       })
       unless options[:no_daemon]
diff --git a/lib/coquelicot/rack/multipart_parser.rb b/lib/coquelicot/rack/multipart_parser.rb
index a4be335..2d99624 100644
--- a/lib/coquelicot/rack/multipart_parser.rb
+++ b/lib/coquelicot/rack/multipart_parser.rb
@@ -23,7 +23,7 @@ module Coquelicot::Rack
   class ManyFieldsStep < Struct.new(:block)
     def initialize(block)
       super
-      @params = Rack::Utils::KeySpaceConstrainedParams.new
+      @params = Rack::Utils::KeySpaceConstrainedParams.new(65536)
     end
 
     def call_handler
@@ -31,7 +31,7 @@ module Coquelicot::Rack
     end
 
     def add_param(name, data)
-      Rack::Utils.normalize_params(@params, name, data)
+      Rack::Utils.default_query_parser.normalize_params(@params, name, data, 100)
     end
 
     # borrowed from Sinatra::Base
-- 
2.11.0

Reply via email to