Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

:escape_html option overridden in Rails 'production' environment #980

Closed
wjordan opened this issue Feb 20, 2018 · 2 comments
Closed

:escape_html option overridden in Rails 'production' environment #980

wjordan opened this issue Feb 20, 2018 · 2 comments

Comments

@wjordan
Copy link
Contributor

wjordan commented Feb 20, 2018

This issue was originally reported by @Justin-Maxwell in #940 (comment).

It seems that starting with version 5 of haml, some lazy-loading behavior changed so that the escape_haml option set in a Rails initializer will be re-set to true in non-development environments (e.g., production).

As mentioned in the linked issue-comment, this is a relatively dangerous bug because it can produce working code in development that breaks only when executed in production.

Here is a minimal demonstration Bash script that reproduces the issue consistently:

haml.sh:

#!/bin/bash

RAILS_PATH=${RAILS_PATH:-/tmp/haml}
RAILS_VERSION=${RAILS_VERSION:-5.0.6}
HAML_VERSION=${HAML_VERSION:-'~> 4'}

rails _${RAILS_VERSION}_ new ${RAILS_PATH} -q > /dev/null

pushd ${RAILS_PATH} > /dev/null
echo 'Haml::Template.options[:escape_html] = false' > config/initializers/haml.rb
echo "gem 'haml', '${HAML_VERSION}'" >> Gemfile
bundle install --quiet
DISABLE_SPRING=1 RAILS_ENV=development bin/rails r 'puts "development: #{Haml::Template.options[:escape_html]}"'
DISABLE_SPRING=1 RAILS_ENV=production bin/rails r 'puts "production: #{Haml::Template.options[:escape_html]}"'
popd > /dev/null
$ echo 'haml4:'; HAML_VERSION='~> 4' ./haml.sh; echo 'haml5:'; HAML_VERSION='~> 5' ./haml.sh
haml4:
development: false
production: false
haml5:
development: false
production: true
@curious725
Copy link

@wjordan Hello,
as I can see you already fixed this issue in #984,
please close this issue.
I spent a lot of time digging into it.

@k0kubun
Copy link
Member

k0kubun commented Jan 19, 2019

sure.

@k0kubun k0kubun closed this as completed Jan 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants