premailer 1.14.2 → 1.15.0

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: 58a86c84cdb9f81b643fda4dfd1f724657e73d8ef1ba2775e90e3f38a5e7cbb6
4
- data.tar.gz: 2e15c7ed98ec6a73c6c8c1daceef050e86dca1496ff63ff84b91c8ebae0992a6
3
+ metadata.gz: 1cbcf7916881885f8da597bf060d93f4faa9a909051f3be3331d63c01b12d07f
4
+ data.tar.gz: 9f507ecec471e66009960367a42ffb618a6f9769fa3bc59358c40e9c0e676bd8
5
5
  SHA512:
6
- metadata.gz: be8096560990ffc0fa62ae3593add156970263ea37a72d79ff439cc8cd097e0d293f4997ed82c1e78e02406923bda419693a751a9f4bb149388acec81b9cef2a
7
- data.tar.gz: 3df71e24a57e2d65e1a852aa58b5fa90df4c98cd730c537b678564f4e437b75b8e2c1586a56d0ceb6e23b47b42bcc345373a5b711bf3ae5d453dece723b2bc22
6
+ metadata.gz: 823f4d6c03aaa776cca778046154c5471312ffcd79296801f94b9cc8b06e5e5a5ca79e5a3f668b03e17fa72ec3419250388ce79c4ddf8cc800c6e9554b783b4b
7
+ data.tar.gz: 43ce39e4a1bc35a4e275072c64ee806b7bb8a735b40eafd67dc2da95671a6299ec9c6df0e35e2d6db86158245b8c9db6815fb96573953a452d95097fa760abe7
@@ -39,25 +39,21 @@ module HtmlToPlainText
39
39
  # remove script tags and content
40
40
  txt.gsub!(/<script.*?\/script>/m, '')
41
41
 
42
- # links with double quotes
43
- txt.gsub!(/<a\s[^\n]*?href=["'](mailto:)?([^"]*)["][^>]*>(.*?)<\/a>/im) do |s|
44
- if $3.empty?
45
- ''
46
- elsif $3.strip.downcase == $2.strip.downcase
47
- $3.strip
48
- else
49
- $3.strip + ' ( ' + $2.strip + ' )'
42
+ # links
43
+ txt.gsub!(/<a\s+([^>]+)>(.*?)<\/a>/im) do |s|
44
+ text = $2.strip
45
+
46
+ match = /href=(['"])(?:mailto:)?(.+?)\1/.match(s)
47
+ if match
48
+ href = match[2]
50
49
  end
51
- end
52
50
 
53
- # links with single quotes
54
- txt.gsub!(/<a\s[^\n]*?href=["'](mailto:)?([^']*)['][^>]*>(.*?)<\/a>/im) do |s|
55
- if $3.empty?
51
+ if text.empty?
56
52
  ''
57
- elsif $3.strip.downcase == $2.strip.downcase
58
- $3.strip
53
+ elsif href.nil? || text.strip.downcase == href.strip.downcase
54
+ text.strip
59
55
  else
60
- $3.strip + ' ( ' + $2.strip + ' )'
56
+ text.strip + ' ( ' + href.strip + ' )'
61
57
  end
62
58
  end
63
59
 
@@ -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,
@@ -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.14.2'.freeze
3
+ VERSION = '1.15.0'.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.14.2
4
+ version: 1.15.0
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-09-21 00:00:00.000000000 Z
11
+ date: 2021-05-13 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.