premailer 1.21.0 → 1.23.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 47eb32064c7ed2912f426d2666ceb0aba0bd7a7f9c235bbc20e86bf961374688
4
- data.tar.gz: 84dc0c5fa0331965aaa552f542d05bc2165cc140b98b25826fa7eb4e0470167e
3
+ metadata.gz: ea6e9ef14eeb9cdffd7e718f976d9e71e50fb1f154c947c9ee9b97399f1aceeb
4
+ data.tar.gz: 02d8f609acce2abb421f607e1937e35e4d36f12c609386bef808378f56e9753c
5
5
  SHA512:
6
- metadata.gz: 3cc088f586ad72db34ed8cf8a44f7b9cdffd4ce1ccbea2009160f228364683f64b7e4891b914c8db4d4c04d3603b792648800912eff6523650c99c5702af17d2
7
- data.tar.gz: 023ecd473bd37bf98b7f9e551bda5f7daf494e4f56bad458aa66d01d9e30e7647d514b13c7560aae97f3b06a00c79228a765cc4698a838d1575adc1ef1b673a6
6
+ metadata.gz: d1e580add5528f240e2170bb2aed29171227d35ce8acc31d5c8ceed7ea3f211072f8db8257f9665bef5838c606c9f77a56a792482c3d5f730025a6448374a4bb
7
+ data.tar.gz: 3afd5c1330b5b1ddff158e77260c0fc87876779e839f5f1beb641ea4c00d424db97c0b5410a566f08ac97a3615cd125c8d9198a77d5edf3ee5959abcc2058440
@@ -61,14 +61,12 @@ class Premailer
61
61
  doc.search("*[@style]").each do |el|
62
62
  style = el.attributes['style'].to_s
63
63
 
64
- declarations = []
65
- style.scan(/\[SPEC\=([\d]+)\[(.[^\]\]]*)\]\]/).each do |declaration|
66
- begin
67
- rs = CssParser::RuleSet.new(nil, declaration[1].to_s, declaration[0].to_i)
68
- declarations << rs
69
- rescue ArgumentError => e
70
- raise e if @options[:rule_set_exceptions]
71
- end
64
+ declarations = style.scan(/\[SPEC\=([\d]+)\[(.[^\]\]]*)\]\]/).filter_map do |declaration|
65
+ rs = Premailer::CachedRuleSet.new(nil, declaration[1].to_s, declaration[0].to_i)
66
+ rs.expand_shorthand!
67
+ rs
68
+ rescue ArgumentError => e
69
+ raise e if @options[:rule_set_exceptions]
72
70
  end
73
71
 
74
72
  # Perform style folding
@@ -9,13 +9,14 @@ module AdapterHelper
9
9
  def is_rgb?(color)
10
10
  pattern = %r{
11
11
  rgb
12
- \(\s* # literal open, with optional whitespace
13
- (\d{1,3}) # capture 1-3 digits
14
- \s*,\s* # comma, with optional whitespace
15
- (\d{1,3}) # capture 1-3 digits
16
- \s*,\s* # comma, with optional whitespace
17
- (\d{1,3}) # capture 1-3 digits
18
- \s*\) # literal close, with optional whitespace
12
+ \(\s* # literal open, with optional whitespace
13
+ (\d{1,3}) # capture 1-3 digits
14
+ (?:\s*,\s*|\s+) # comma or whitespace
15
+ (\d{1,3}) # capture 1-3 digits
16
+ (?:\s*,\s*|\s+) # comma or whitespacee
17
+ (\d{1,3}) # capture 1-3 digits
18
+ \s*(?:\/\s*\d*\.?\d*%?)? # optional alpha modifier
19
+ \s*\) # literal close, with optional whitespace
19
20
  }x
20
21
 
21
22
  pattern.match(color)
@@ -0,0 +1,12 @@
1
+ class Premailer
2
+ class CachedRuleSet < CssParser::RuleSet
3
+ # we call this early to find errors but css-parser calls it in .merge again
4
+ # so to prevent slowdown and bugs we refuse to run it twice on the same ruleset
5
+ # ideally should be upstreamed into css-parser
6
+ def expand_shorthand!
7
+ super unless @expand_shorthand
8
+ ensure
9
+ @expand_shorthand = true
10
+ end
11
+ end
12
+ end
@@ -1,4 +1,4 @@
1
1
  class Premailer
2
2
  # Premailer version.
3
- VERSION = '1.21.0'.freeze
3
+ VERSION = '1.23.0'.freeze
4
4
  end
data/lib/premailer.rb CHANGED
@@ -9,3 +9,4 @@ require 'premailer/adapter'
9
9
  require 'premailer/adapter/rgb_to_hex'
10
10
  require 'premailer/html_to_plain_text'
11
11
  require 'premailer/premailer'
12
+ require 'premailer/cached_rule_set'
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.21.0
4
+ version: 1.23.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Dunae
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-03-21 00:00:00.000000000 Z
11
+ date: 2024-03-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: css_parser
@@ -92,14 +92,14 @@ dependencies:
92
92
  requirements:
93
93
  - - "~>"
94
94
  - !ruby/object:Gem::Version
95
- version: '1.13'
95
+ version: '1.16'
96
96
  type: :development
97
97
  prerelease: false
98
98
  version_requirements: !ruby/object:Gem::Requirement
99
99
  requirements:
100
100
  - - "~>"
101
101
  - !ruby/object:Gem::Version
102
- version: '1.13'
102
+ version: '1.16'
103
103
  - !ruby/object:Gem::Dependency
104
104
  name: redcarpet
105
105
  requirement: !ruby/object:Gem::Requirement
@@ -187,6 +187,7 @@ files:
187
187
  - lib/premailer/adapter/nokogiri_fast.rb
188
188
  - lib/premailer/adapter/nokogumbo.rb
189
189
  - lib/premailer/adapter/rgb_to_hex.rb
190
+ - lib/premailer/cached_rule_set.rb
190
191
  - lib/premailer/executor.rb
191
192
  - lib/premailer/html_to_plain_text.rb
192
193
  - lib/premailer/premailer.rb
@@ -197,7 +198,8 @@ licenses:
197
198
  - BSD-3-Clause
198
199
  metadata:
199
200
  yard.run: yri
200
- post_install_message:
201
+ rubygems_mfa_required: 'true'
202
+ post_install_message:
201
203
  rdoc_options: []
202
204
  require_paths:
203
205
  - lib
@@ -205,15 +207,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
205
207
  requirements:
206
208
  - - ">="
207
209
  - !ruby/object:Gem::Version
208
- version: 2.7.0
210
+ version: '3.0'
209
211
  required_rubygems_version: !ruby/object:Gem::Requirement
210
212
  requirements:
211
213
  - - ">="
212
214
  - !ruby/object:Gem::Version
213
215
  version: '0'
214
216
  requirements: []
215
- rubygems_version: 3.1.6
216
- signing_key:
217
+ rubygems_version: 3.4.10
218
+ signing_key:
217
219
  specification_version: 4
218
220
  summary: Preflight for HTML e-mail.
219
221
  test_files: []