FIX: correct race condition loading library
In some very rare cases CssParser could be loaded but CssParser::Parser not this ensures we check for the actual constant we plan to call for concurrent digest generations
This commit is contained in:
parent
f7c648e3af
commit
d05b724c4e
|
@ -40,9 +40,11 @@ module Email
|
||||||
@custom_styles = {}
|
@custom_styles = {}
|
||||||
|
|
||||||
if !css.blank?
|
if !css.blank?
|
||||||
require 'css_parser' unless defined?(CssParser)
|
# there is a minor race condition here, CssParser could be
|
||||||
|
# loaded by ::CssParser::Parser not loaded
|
||||||
|
require 'css_parser' unless defined?(::CssParser::Parser)
|
||||||
|
|
||||||
parser = CssParser::Parser.new(import: false)
|
parser = ::CssParser::Parser.new(import: false)
|
||||||
parser.load_string!(css)
|
parser.load_string!(css)
|
||||||
parser.each_selector do |selector, value|
|
parser.each_selector do |selector, value|
|
||||||
@custom_styles[selector] ||= +''
|
@custom_styles[selector] ||= +''
|
||||||
|
|
Loading…
Reference in New Issue