Skip to content

Commit

Permalink
fix an issue with Rack 3 and request.body.rewind statements + upgrade…
Browse files Browse the repository at this point in the history
… to the last version of Nokogiri (fix issue #237)
  • Loading branch information
did committed Oct 4, 2024
1 parent 25420ca commit c3cbc00
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 35 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@ log
dragonfly.log
.byebug_history
TODO.md
bin/generate_non_regression_with_scope_spec.rb
56 changes: 29 additions & 27 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ PATH
moneta (~> 1.6.0)
morphine (~> 0.1.1)
multi_json (~> 1.15.0)
nokogiri (~> 1.15.6)
nokogiri (~> 1.16.7)
parser (~> 3.3)
pony (~> 1.12)
rack-cache (>= 1.7, < 2)
Expand All @@ -30,16 +30,17 @@ GEM
remote: https://rubygems.org/
specs:
RedCloth (4.3.4)
activesupport (7.1.3.4)
activesupport (7.2.1)
base64
bigdecimal
concurrent-ruby (~> 1.0, >= 1.0.2)
concurrent-ruby (~> 1.0, >= 1.3.1)
connection_pool (>= 2.2.5)
drb
i18n (>= 1.6, < 2)
logger (>= 1.4.2)
minitest (>= 5.1)
mutex_m
tzinfo (~> 2.0)
securerandom (>= 0.3)
tzinfo (~> 2.0, >= 2.0.5)
addressable (2.8.7)
public_suffix (>= 2.0.2, < 7.0)
ast (2.4.2)
Expand All @@ -50,12 +51,12 @@ GEM
bson (4.15.0)
chronic (0.10.2)
colorize (1.1.0)
concurrent-ruby (1.2.3)
concurrent-ruby (1.3.4)
connection_pool (2.4.1)
crass (1.0.6)
date (3.3.4)
diff-lcs (1.5.1)
docile (1.4.0)
docile (1.4.1)
dragonfly (1.4.0)
addressable (~> 2.3)
multi_json (~> 1.0)
Expand All @@ -71,7 +72,7 @@ GEM
httparty (0.21.0)
mini_mime (>= 1.0.0)
multi_xml (>= 0.5.2)
i18n (1.14.4)
i18n (1.14.6)
concurrent-ruby (~> 1.0)
i18n-spec (0.6.0)
iso
Expand All @@ -88,28 +89,28 @@ GEM
attr_extras (~> 7.1.0)
colorize
stringex (~> 2.8.5)
logger (1.6.1)
mail (2.8.1)
mini_mime (>= 0.1.1)
net-imap
net-pop
net-smtp
memory_profiler (1.0.1)
memory_profiler (1.1.0)
mime-types (3.5.2)
mime-types-data (~> 3.2015)
mime-types-data (3.2024.0604)
mime-types-data (3.2024.1001)
mimetype-fu (0.1.2)
mini_mime (1.1.5)
mini_portile2 (2.8.7)
minitest (5.24.0)
minitest (5.25.1)
moneta (1.6.0)
mongo (2.18.3)
bson (>= 4.14.1, < 5.0.0)
morphine (0.1.1)
multi_json (1.15.0)
multi_xml (0.7.1)
bigdecimal (~> 3.1)
mutex_m (0.2.0)
net-imap (0.4.14)
net-imap (0.4.16)
date
net-protocol
net-pop (0.1.2)
Expand All @@ -118,21 +119,23 @@ GEM
timeout
net-smtp (0.5.0)
net-protocol
nio4r (2.7.1)
nokogiri (1.15.6)
nio4r (2.7.3)
nokogiri (1.16.7)
mini_portile2 (~> 2.8.2)
racc (~> 1.4)
nokogiri (1.16.7-x86_64-darwin)
racc (~> 1.4)
origin (2.3.1)
parser (3.3.5.0)
ast (~> 2.4.1)
racc
pony (1.13.1)
mail (>= 2.0)
public_suffix (6.0.0)
puma (6.4.2)
public_suffix (6.0.1)
puma (6.4.3)
nio4r (~> 2.0)
racc (1.8.0)
rack (3.0.10)
racc (1.8.1)
rack (3.1.7)
rack-cache (1.17.0)
rack (>= 0.4)
rack-mini-profiler (0.10.7)
Expand All @@ -144,9 +147,8 @@ GEM
rack (>= 1.3)
rack_csrf (2.6.0)
rack (>= 1.1.0)
rake (13.1.0)
rexml (3.3.1)
strscan
rake (13.2.1)
rexml (3.3.8)
rspec (3.12.0)
rspec-core (~> 3.12.0)
rspec-expectations (~> 3.12.0)
Expand All @@ -163,19 +165,19 @@ GEM
sanitize (6.0.2)
crass (~> 1.0.2)
nokogiri (>= 1.12.0)
securerandom (0.3.1)
simplecov (0.22.0)
docile (~> 1.1)
simplecov-html (~> 0.11)
simplecov_json_formatter (~> 0.1)
simplecov-html (0.12.3)
simplecov-html (0.13.1)
simplecov_json_formatter (0.1.4)
stackprof (0.2.26)
stringex (2.8.6)
strscan (3.1.0)
temple (0.10.3)
thor (1.3.1)
tilt (2.3.0)
timecop (0.9.8)
thor (1.3.2)
tilt (2.4.0)
timecop (0.9.10)
timeout (0.4.1)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
Expand Down
3 changes: 2 additions & 1 deletion lib/locomotive/steam/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class << self
def default_middlewares
server, configuration = self, self.configuration

-> (stack) {
-> (stack) {
use(Rack::Rewrite) { r301 %r{^/(.*)/$}, '/$1' }
use Middlewares::Favicon

Expand All @@ -38,6 +38,7 @@ def default_middlewares
use Dragonfly::Middleware, :steam

use Rack::Lint
use Rack::RewindableInput::Middleware
use Rack::Session::Moneta, configuration.moneta

use Rack::MiniProfiler if ENV['PROFILER']
Expand Down
2 changes: 1 addition & 1 deletion locomotivecms_steam.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
spec.add_development_dependency 'mongo', '~> 2.18.2'
spec.add_development_dependency 'origin', '~> 2.3.1'

spec.add_dependency 'nokogiri', '~> 1.15.6'
spec.add_dependency 'nokogiri', '~> 1.16.7'
spec.add_dependency 'sanitize', '~> 6.0.1'
spec.add_dependency 'morphine', '~> 0.1.1'
spec.add_dependency 'httparty', '~> 0.21.0'
Expand Down
3 changes: 2 additions & 1 deletion spec/integration/server/contact_form_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,8 @@ def app
def post_contact_form(url, params, json = false, follow_redirect = false, env = {})
if json
url += '.json'
params = params.symbolize_keys
params = JSON.generate(params.symbolize_keys)
env['CONTENT_TYPE'] = 'application/json'
end

post url, params, env
Expand Down
10 changes: 5 additions & 5 deletions spec/unit/middlewares/section_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@
locale: 'en')
}

let(:body) { '' }

before do
env['rack.input'] = StringIO.new(body)
env['steam.page'] = page
env['steam.services'] = services
env['steam.locale'] = :en
Expand All @@ -52,11 +55,8 @@
end

context "the content of the section is in the request body" do

before do
allow(env['steam.request']).to receive(:body).and_return(StringIO.new(
%({ "section_content": { "id": "dropzone-42", "settings": { "name": "modified HTML" } } })
))
let(:body) do
%({ "section_content": { "id": "dropzone-42", "settings": { "name": "modified HTML" } } })
end

it 'renders the HTML code related to the section' do
Expand Down

0 comments on commit c3cbc00

Please sign in to comment.