html-proofer 5.0.2 → 5.0.3

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: 9ee4cb46fd2691b7c8ed80a1e11069fa8d9f4b0058e69ce00bd15da9fcf3b3b4
4
- data.tar.gz: cfc205c660310bde3b5329079ee1de8aa4eb3083b95c691386ccc491ddca628c
3
+ metadata.gz: 337d1725f7139e6efda6d350b83b15ecfd51eb67ee44e068f1b29859104320dd
4
+ data.tar.gz: 3ad1dcdb66a4789853e92303a1cd6e9872d95db137ab589df75f5f6af00d7ed0
5
5
  SHA512:
6
- metadata.gz: 567f404dec415cd1c21f04f6fe951cc217a3d918f8434ca1b6ec2b63d58efad89513408808626d82f7fc56f898c55a80d10560e8e36b1185c044e0b067833f4a
7
- data.tar.gz: 21103cf7d04e277d886226a8e89f1720b346b353e6b8c838247a70d4360c6e1c596ea99bddb243e7dd3026febad085c5b7f163ee0a7617c127d8ad5d7237a325
6
+ metadata.gz: 656b20f4feeffc2dca48e38e42d510c8b7f5d4e7f563167429e0c687c0b1a938008dfe8bb7e21591ed8a5c76fd7ea8c20d63b78f2c71fcf54a3a9bcf55970a7e
7
+ data.tar.gz: 490f87dcd3a849a55c2051e56e93e8b65e47e18ffea0fd82061b8418736709cff5ec5230fd84d937e7b748ccec19c644650ef970dda49a0ce100f57914be6418
@@ -82,10 +82,25 @@ module HTMLProofer
82
82
  !blank?(srcset) && srcset.split(",").size > 1
83
83
  end
84
84
 
85
+ # From https://github.com/sindresorhus/srcset/blob/f7c48acd7facf18e94dec47e6b96e84e0f0e69dc/index.js#LL1-L16C71
86
+ # This regex represents a loose rule of an “image candidate string”; see https://html.spec.whatwg.org/multipage/images.html#srcset-attribute
87
+ # An “image candidate string” roughly consists of the following:
88
+ # 1. Zero or more whitespace characters.
89
+ # 2. A non-empty URL that does not start or end with `,`.
90
+ # 3. Zero or more whitespace characters.
91
+ # 4. An optional “descriptor” that starts with a whitespace character.
92
+ # 5. Zero or more whitespace characters.
93
+ # 6. Each image candidate string is separated by a `,`.
94
+ # We intentionally implement a loose rule here so that we can perform more aggressive error handling and reporting in the below code.
95
+
96
+ IMAGE_CANDIDATE_REGEX = /\s*([^,]\S*[^,](?:\s+[^,]+)?)\s*(?:,|$)/
97
+
85
98
  def srcsets
86
99
  return nil if blank?(srcset)
87
100
 
88
- srcset.split(",").map(&:strip)
101
+ srcset.split(IMAGE_CANDIDATE_REGEX).select.with_index do |_part, idx|
102
+ idx.odd?
103
+ end.map(&:strip)
89
104
  end
90
105
 
91
106
  def multiple_sizes?
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module HTMLProofer
4
- VERSION = "5.0.2"
4
+ VERSION = "5.0.3"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: html-proofer
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.2
4
+ version: 5.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Garen Torikian
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-11-15 00:00:00.000000000 Z
11
+ date: 2022-12-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -306,7 +306,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
306
306
  - !ruby/object:Gem::Version
307
307
  version: '0'
308
308
  requirements: []
309
- rubygems_version: 3.3.7
309
+ rubygems_version: 3.3.26
310
310
  signing_key:
311
311
  specification_version: 4
312
312
  summary: A set of tests to validate your HTML output. These tests check if your image