From 1b68715542c730a738cf78a88a41c004e9bd7ea6 Mon Sep 17 00:00:00 2001 From: Jason Lee Date: Fri, 20 Dec 2019 15:23:09 +0800 Subject: [PATCH] Fix #84 session.id error with upgrade Rails 6.0.2.1 or Rack 2.0.8 https://github.com/rack/rack/commit/7fecaee81f59926b6e1913511c90650e76673b38 --- lib/rucaptcha/controller_helpers.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/rucaptcha/controller_helpers.rb b/lib/rucaptcha/controller_helpers.rb index 7f6028a..2caaaf8 100644 --- a/lib/rucaptcha/controller_helpers.rb +++ b/lib/rucaptcha/controller_helpers.rb @@ -8,9 +8,14 @@ module RuCaptcha # session key of rucaptcha def rucaptcha_sesion_key_key + session_id = session.respond_to?(:id) ? session.id : session[:session_id] warning_when_session_invalid if session_id.blank? - ['rucaptcha-session', session_id].join(':') + + # With https://github.com/rack/rack/commit/7fecaee81f59926b6e1913511c90650e76673b38 + # to protected session_id into secret + session_id_digest = Digest::SHA256.hexdigest(session_id.inspect) + ['rucaptcha-session', session_id_digest].join(':') end # Generate a new Captcha