premailer 1.13.0 → 1.14.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c7882cf6e028e4d0f2bfb61a5fe7fdcf86f27f38771110bfa2adb01e774bb9e8
4
- data.tar.gz: 34d2f2dd133d9e339927ca08c4f358028b9bc1f9ab9a957a0702410b4bbfd98d
3
+ metadata.gz: e62efcd15fd7c988efb25a7dc326adb7ffd4531bd3aabff7fe0de0a7099ab9e8
4
+ data.tar.gz: 4cee57fc796dd4409c96b6ff5c067441d182a5e0a44604ed2b6b02836018d625
5
5
  SHA512:
6
- metadata.gz: b0016714ba7bf448622523699f89d68bad9c10127f3dc2ed76c5bde9cc6829edb31e1483a9c30e37f8214e46f45d43c0f260e8d743d63947340fb4a026676df6
7
- data.tar.gz: f63d9445ddc63a0f39370599f92d1b4a52c783aa72f447e333b3a867e3cb4290d107659278de44cfc070d208bb66b1c538eeef9a7e79316c4e1b46cf7fa07b4c
6
+ metadata.gz: b888135d71b9b96555264ec940bc06b19d86019e4a446751be02fcfd6d2bfc7862357edee3405b4076c23e701a5794767799a862133f7aef91fa650c5979db80
7
+ data.tar.gz: a8f45e8985ef02a82825e29b24653351430ee3f8482696d276858ea3deaf423499a323fa897d19533b120fea9ab2a38be2bf1f229f41572f61745aa1f3e9c958
data/README.md CHANGED
@@ -68,7 +68,7 @@ Premailer::Adapter.use = :nokogiri_fast
68
68
 
69
69
  ## Ruby Compatibility
70
70
 
71
- Premailer is tested on Ruby 2.1 and above. JRuby support is close; contributors are welcome. Checkout the latest build status on the [Travis CI dashboard](https://travis-ci.org/#!/premailer/premailer).
71
+ See .travis.yml for which ruby versions are tested. JRuby support is close, contributors are welcome. Checkout the latest build status on the [Travis CI dashboard](https://travis-ci.org/#!/premailer/premailer).
72
72
 
73
73
  ## Premailer-specific CSS
74
74
 
@@ -55,9 +55,7 @@ class Premailer
55
55
  end
56
56
 
57
57
  # Remove script tags
58
- if @options[:remove_scripts]
59
- doc.search("script").remove
60
- end
58
+ doc.search("script").remove if @options[:remove_scripts]
61
59
 
62
60
  # Read STYLE attributes and perform folding
63
61
  doc.search("*[@style]").each do |el|
@@ -75,18 +73,33 @@ class Premailer
75
73
 
76
74
  # Duplicate CSS attributes as HTML attributes
77
75
  if Premailer::RELATED_ATTRIBUTES.has_key?(el.name) && @options[:css_to_attributes]
78
- Premailer::RELATED_ATTRIBUTES[el.name].each do |css_att, html_att|
79
- if el[html_att].nil? and not merged[css_att].empty?
80
- new_html_att = merged[css_att].gsub(/url\(['"](.*)['"]\)/, '\1').gsub(/;$|\s*!important/, '').strip
81
- el[html_att] = css_att.end_with?('color') && @options[:rgb_to_hex_attributes] ? ensure_hex(new_html_att) : new_html_att
76
+ Premailer::RELATED_ATTRIBUTES[el.name].each do |css_attr, html_attr|
77
+ if el[html_attr].nil? and not merged[css_attr].empty?
78
+ new_val = merged[css_attr].dup
79
+
80
+ # Remove url() function wrapper
81
+ new_val.gsub!(/url\((['"])(.*?)\1\)/, '\2')
82
+
83
+ # Remove !important, trailing semi-colon, and leading/trailing whitespace
84
+ new_val.gsub!(/;$|\s*!important/, '').strip!
85
+
86
+ # For width and height tags, remove px units
87
+ new_val.gsub!(/(\d+)px/, '\1') if %w[width height].include?(html_attr)
88
+
89
+ # For color-related tags, convert RGB to hex if specified by options
90
+ new_val = ensure_hex(new_val) if css_attr.end_with?('color') && @options[:rgb_to_hex_attributes]
91
+
92
+ el[html_attr] = new_val
82
93
  end
94
+
83
95
  unless @options[:preserve_style_attribute]
84
96
  merged.instance_variable_get("@declarations").tap do |declarations|
85
- declarations.delete(css_att)
97
+ declarations.delete(css_attr)
86
98
  end
87
99
  end
88
100
  end
89
101
  end
102
+
90
103
  # Collapse multiple rules into one as much as possible.
91
104
  merged.create_shorthand! if @options[:create_shorthands]
92
105
 
@@ -77,18 +77,33 @@ class Premailer
77
77
 
78
78
  # Duplicate CSS attributes as HTML attributes
79
79
  if Premailer::RELATED_ATTRIBUTES.has_key?(el.name) && @options[:css_to_attributes]
80
- Premailer::RELATED_ATTRIBUTES[el.name].each do |css_att, html_att|
81
- if el[html_att].nil? and not merged[css_att].empty?
82
- new_html_att = merged[css_att].gsub(/url\(['"](.*)['"]\)/, '\1').gsub(/;$|\s*!important/, '').strip
83
- el[html_att] = css_att.end_with?('color') && @options[:rgb_to_hex_attributes] ? ensure_hex(new_html_att) : new_html_att
80
+ Premailer::RELATED_ATTRIBUTES[el.name].each do |css_attr, html_attr|
81
+ if el[html_attr].nil? and not merged[css_attr].empty?
82
+ new_val = merged[css_attr].dup
83
+
84
+ # Remove url() function wrapper
85
+ new_val.gsub!(/url\((['"])(.*?)\1\)/, '\2')
86
+
87
+ # Remove !important, trailing semi-colon, and leading/trailing whitespace
88
+ new_val.gsub!(/;$|\s*!important/, '').strip!
89
+
90
+ # For width and height tags, remove px units
91
+ new_val.gsub!(/(\d+)px/, '\1') if %w[width height].include?(html_attr)
92
+
93
+ # For color-related tags, convert RGB to hex if specified by options
94
+ new_val = ensure_hex(new_val) if css_attr.end_with?('color') && @options[:rgb_to_hex_attributes]
95
+
96
+ el[html_attr] = new_val
84
97
  end
98
+
85
99
  unless @options[:preserve_style_attribute]
86
100
  merged.instance_variable_get("@declarations").tap do |declarations|
87
- declarations.delete(css_att)
101
+ declarations.delete(css_attr)
88
102
  end
89
103
  end
90
104
  end
91
105
  end
106
+
92
107
  # Collapse multiple rules into one as much as possible.
93
108
  merged.create_shorthand! if @options[:create_shorthands]
94
109
 
@@ -55,9 +55,7 @@ class Premailer
55
55
  end
56
56
 
57
57
  # Remove script tags
58
- if @options[:remove_scripts]
59
- doc.search("script").remove
60
- end
58
+ doc.search("script").remove if @options[:remove_scripts]
61
59
 
62
60
  # Read STYLE attributes and perform folding
63
61
  doc.search("*[@style]").each do |el|
@@ -75,18 +73,33 @@ class Premailer
75
73
 
76
74
  # Duplicate CSS attributes as HTML attributes
77
75
  if Premailer::RELATED_ATTRIBUTES.has_key?(el.name) && @options[:css_to_attributes]
78
- Premailer::RELATED_ATTRIBUTES[el.name].each do |css_att, html_att|
79
- if el[html_att].nil? and not merged[css_att].empty?
80
- new_html_att = merged[css_att].gsub(/url\(['"](.*)['"]\)/, '\1').gsub(/;$|\s*!important/, '').strip
81
- el[html_att] = css_att.end_with?('color') && @options[:rgb_to_hex_attributes] ? ensure_hex(new_html_att) : new_html_att
76
+ Premailer::RELATED_ATTRIBUTES[el.name].each do |css_attr, html_attr|
77
+ if el[html_attr].nil? and not merged[css_attr].empty?
78
+ new_val = merged[css_attr].dup
79
+
80
+ # Remove url() function wrapper
81
+ new_val.gsub!(/url\((['"])(.*?)\1\)/, '\2')
82
+
83
+ # Remove !important, trailing semi-colon, and leading/trailing whitespace
84
+ new_val.gsub!(/;$|\s*!important/, '').strip!
85
+
86
+ # For width and height tags, remove px units
87
+ new_val.gsub!(/(\d+)px/, '\1') if %w[width height].include?(html_attr)
88
+
89
+ # For color-related tags, convert RGB to hex if specified by options
90
+ new_val = ensure_hex(new_val) if css_attr.end_with?('color') && @options[:rgb_to_hex_attributes]
91
+
92
+ el[html_attr] = new_val
82
93
  end
94
+
83
95
  unless @options[:preserve_style_attribute]
84
96
  merged.instance_variable_get("@declarations").tap do |declarations|
85
- declarations.delete(css_att)
97
+ declarations.delete(css_attr)
86
98
  end
87
99
  end
88
100
  end
89
101
  end
102
+
90
103
  # Collapse multiple rules into one as much as possible.
91
104
  merged.create_shorthand! if @options[:create_shorthands]
92
105
 
@@ -178,7 +178,7 @@ class Premailer
178
178
  # @option options [String] :output_encoding Output encoding option for Nokogiri adapter. Should be set to "US-ASCII" to output HTML entities instead of Unicode characters.
179
179
  # @option options [Boolean] :create_shorthands Combine several properties into a shorthand one, e.g. font: style weight size. Default is true.
180
180
  # @option options [Boolean] :html_fragment Handle HTML fragment without any HTML content wrappers. Default is false.
181
- # @option options [Boolean] :drop_unmergeable_css_rules Do not include unmergeable css rules in a <tt><style><tt> tag. Default is false.
181
+ # @option options [Boolean] :drop_unmergeable_css_rules Do not include unmergeable css rules in a <tt><style><tt> tag. Default is false.
182
182
  def initialize(html, options = {})
183
183
  @options = {:warn_level => Warnings::SAFE,
184
184
  :line_length => 65,
@@ -309,7 +309,7 @@ protected
309
309
  link_uri = File.join(File.dirname(@html_file), tag.attributes['href'].to_s.sub!(@base_url.to_s, ''))
310
310
  end
311
311
  # if the file does not exist locally, try to grab the remote reference
312
- unless File.exists?(link_uri)
312
+ unless File.exist?(link_uri)
313
313
  link_uri = Premailer.resolve_link(tag.attributes['href'].to_s, @html_file)
314
314
  end
315
315
  else
@@ -499,14 +499,8 @@ public
499
499
  def self.canonicalize(uri) # :nodoc:
500
500
  u = uri.kind_of?(Addressable::URI) ? uri : Addressable::URI.parse(uri.to_s)
501
501
  u.normalize!
502
- newpath = u.path
503
- while newpath.gsub!(%r{([^/]+)/\.\./?}) { |match|
504
- $1 == '..' ? match : ''
505
- } do end
506
- newpath = newpath.gsub(%r{/\./}, '/').sub(%r{/\.\z}, '/')
507
- u.path = newpath
508
- u.to_s
509
- end
502
+ u.to_s
503
+ end
510
504
 
511
505
  # Check <tt>CLIENT_SUPPORT_FILE</tt> for any CSS warnings
512
506
  def check_client_support # :nodoc:
@@ -1,4 +1,4 @@
1
1
  class Premailer
2
2
  # Premailer version.
3
- VERSION = '1.13.0'.freeze
3
+ VERSION = '1.14.3'.freeze
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: premailer
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.13.0
4
+ version: 1.14.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Dunae
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-08-04 00:00:00.000000000 Z
11
+ date: 2021-04-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: css_parser
@@ -207,7 +207,8 @@ files:
207
207
  - lib/premailer/version.rb
208
208
  - misc/client_support.yaml
209
209
  homepage: https://github.com/premailer/premailer
210
- licenses: []
210
+ licenses:
211
+ - BSD-3-Clause
211
212
  metadata:
212
213
  yard.run: yri
213
214
  post_install_message:
@@ -225,7 +226,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
225
226
  - !ruby/object:Gem::Version
226
227
  version: '0'
227
228
  requirements: []
228
- rubygems_version: 3.1.3
229
+ rubygems_version: 3.2.16
229
230
  signing_key:
230
231
  specification_version: 4
231
232
  summary: Preflight for HTML e-mail.