html-proofer 5.0.8 → 5.0.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/html_proofer/attribute/url.rb +19 -5
- data/lib/html_proofer/cache.rb +4 -3
- data/lib/html_proofer/check/images.rb +12 -12
- data/lib/html_proofer/configuration.rb +2 -2
- data/lib/html_proofer/element.rb +7 -7
- data/lib/html_proofer/log.rb +3 -3
- data/lib/html_proofer/runner.rb +2 -2
- data/lib/html_proofer/url_validator/internal.rb +1 -3
- data/lib/html_proofer/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6ecfce010632739b71710eb8b6c91b8ca6ca4828e2b6e7df254c2cc6b00462a4
|
4
|
+
data.tar.gz: 50d19f3c6145d6184dc5d463cfde6684d609f797277b437103bf8114387d8570
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 92253a2948b3492043b548c1ae3ccf23dc66e9da5dd14bdf6724e9c6f377ce53960fa4b689390d4242e1cd3090773b3de0caba8550a61cebde932564a2811a4d
|
7
|
+
data.tar.gz: 8c9ad6f1cdd747241d46e06ff444f84d7de7a73f6ae71b8b9e73406e11ad8748bf29ff3db3d837e7535ddb4c235e87f5b52b8999992811ae87e2dc00bbd96a76
|
@@ -52,7 +52,8 @@ module HTMLProofer
|
|
52
52
|
|
53
53
|
def ignore?
|
54
54
|
return true if /^javascript:/.match?(@url)
|
55
|
-
|
55
|
+
|
56
|
+
true if ignores_pattern?(@runner.options[:ignore_urls])
|
56
57
|
end
|
57
58
|
|
58
59
|
def valid?
|
@@ -220,11 +221,24 @@ module HTMLProofer
|
|
220
221
|
@url.to_s.sub(/##{hash}/, "")
|
221
222
|
end
|
222
223
|
|
223
|
-
# catch any obvious issues
|
224
|
+
# catch any obvious issues
|
224
225
|
private def clean_url!
|
225
|
-
|
226
|
-
|
227
|
-
|
226
|
+
parsed_url = Addressable::URI.parse(@url)
|
227
|
+
url = if parsed_url.scheme.nil?
|
228
|
+
parsed_url
|
229
|
+
else
|
230
|
+
parsed_url.normalize
|
231
|
+
end.to_s
|
232
|
+
|
233
|
+
# normalize strips this off, which causes issues with cache
|
234
|
+
@url = if @url.end_with?("/") && !url.end_with?("/")
|
235
|
+
"#{url}/"
|
236
|
+
elsif !@url.end_with?("/") && url.end_with?("/")
|
237
|
+
url.chop
|
238
|
+
else
|
239
|
+
url
|
240
|
+
end
|
241
|
+
rescue Addressable::URI::InvalidURIError # rubocop:disable Lint/SuppressedException -- error will be reported at check time
|
228
242
|
end
|
229
243
|
|
230
244
|
private def swap_urls!
|
data/lib/html_proofer/cache.rb
CHANGED
@@ -41,7 +41,7 @@ module HTMLProofer
|
|
41
41
|
end
|
42
42
|
|
43
43
|
def parsed_timeframe(timeframe)
|
44
|
-
return
|
44
|
+
return if timeframe.nil?
|
45
45
|
|
46
46
|
time, date = timeframe.match(/(\d+)(\D)/).captures
|
47
47
|
time = time.to_i
|
@@ -252,7 +252,7 @@ module HTMLProofer
|
|
252
252
|
SECONDS_PER_HOUR = 3600
|
253
253
|
SECONDS_PER_DAY = 86400
|
254
254
|
SECONDS_PER_WEEK = 604800
|
255
|
-
SECONDS_PER_MONTH = 2629746
|
255
|
+
SECONDS_PER_MONTH = 2629746 # 1/12 of a gregorian year
|
256
256
|
|
257
257
|
private def time_ago(measurement, unit)
|
258
258
|
case unit
|
@@ -269,7 +269,8 @@ module HTMLProofer
|
|
269
269
|
|
270
270
|
private def url_matches_type?(url, type)
|
271
271
|
return true if type == :internal && url !~ URI_REGEXP
|
272
|
-
|
272
|
+
|
273
|
+
true if type == :external && url =~ URI_REGEXP
|
273
274
|
end
|
274
275
|
|
275
276
|
private def cleaned_url(url)
|
@@ -20,18 +20,6 @@ module HTMLProofer
|
|
20
20
|
# does the image exist?
|
21
21
|
if missing_src?
|
22
22
|
add_failure("image has no src or srcset attribute", element: @img)
|
23
|
-
elsif @img.url.protocol_relative?
|
24
|
-
add_failure(
|
25
|
-
"image link #{@img.url} is a protocol-relative URL, use explicit https:// instead",
|
26
|
-
element: @img,
|
27
|
-
)
|
28
|
-
elsif @img.url.remote?
|
29
|
-
add_to_external_urls(@img.url, @img.line)
|
30
|
-
elsif !@img.url.exists? && !@img.multiple_srcsets? && !@img.multiple_sizes?
|
31
|
-
add_failure(
|
32
|
-
"internal image #{@img.url.raw_attribute} does not exist",
|
33
|
-
element: @img,
|
34
|
-
)
|
35
23
|
elsif @img.multiple_srcsets? || @img.multiple_sizes?
|
36
24
|
@img.srcsets_wo_sizes.each do |srcset|
|
37
25
|
srcset_url = HTMLProofer::Attribute::Url.new(@runner, srcset, base_url: @img.base_url, source: @img.url.source, filename: @img.url.filename, extract_size: true)
|
@@ -47,6 +35,18 @@ module HTMLProofer
|
|
47
35
|
add_failure("internal image #{srcset} does not exist", element: @img)
|
48
36
|
end
|
49
37
|
end
|
38
|
+
elsif @img.url.protocol_relative?
|
39
|
+
add_failure(
|
40
|
+
"image link #{@img.url} is a protocol-relative URL, use explicit https:// instead",
|
41
|
+
element: @img,
|
42
|
+
)
|
43
|
+
elsif @img.url.remote?
|
44
|
+
add_to_external_urls(@img.url, @img.line)
|
45
|
+
elsif !@img.url.exists? && !@img.multiple_srcsets? && !@img.multiple_sizes?
|
46
|
+
add_failure(
|
47
|
+
"internal image #{@img.url.raw_attribute} does not exist",
|
48
|
+
element: @img,
|
49
|
+
)
|
50
50
|
end
|
51
51
|
|
52
52
|
# if this is an img element, check that the alt attribute is present
|
@@ -233,8 +233,8 @@ module HTMLProofer
|
|
233
233
|
arg.split(",").each_with_object({}) do |s, hsh|
|
234
234
|
split = s.split(/(?<!\\):/, 2)
|
235
235
|
|
236
|
-
re = split[0].gsub(
|
237
|
-
string = split[1].gsub(
|
236
|
+
re = split[0].gsub("\\:", ":")
|
237
|
+
string = split[1].gsub("\\:", ":")
|
238
238
|
hsh[Regexp.new(re)] = string
|
239
239
|
end
|
240
240
|
end
|
data/lib/html_proofer/element.rb
CHANGED
@@ -27,7 +27,7 @@ module HTMLProofer
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def meta_content
|
30
|
-
return
|
30
|
+
return unless meta_tag?
|
31
31
|
|
32
32
|
@node["content"]
|
33
33
|
end
|
@@ -37,7 +37,7 @@ module HTMLProofer
|
|
37
37
|
end
|
38
38
|
|
39
39
|
def src
|
40
|
-
return
|
40
|
+
return if !img_tag? && !script_tag? && !source_tag?
|
41
41
|
|
42
42
|
@node["src"]
|
43
43
|
end
|
@@ -51,7 +51,7 @@ module HTMLProofer
|
|
51
51
|
end
|
52
52
|
|
53
53
|
def srcset
|
54
|
-
return
|
54
|
+
return if !img_tag? && !source_tag?
|
55
55
|
|
56
56
|
@node["srcset"]
|
57
57
|
end
|
@@ -61,7 +61,7 @@ module HTMLProofer
|
|
61
61
|
end
|
62
62
|
|
63
63
|
def href
|
64
|
-
return
|
64
|
+
return if !a_tag? && !link_tag?
|
65
65
|
|
66
66
|
@node["href"]
|
67
67
|
end
|
@@ -96,7 +96,7 @@ module HTMLProofer
|
|
96
96
|
IMAGE_CANDIDATE_REGEX = /\s*([^,]\S*[^,](?:\s+[^,]+)?)\s*(?:,|$)/
|
97
97
|
|
98
98
|
def srcsets
|
99
|
-
return
|
99
|
+
return if blank?(srcset)
|
100
100
|
|
101
101
|
srcset.split(IMAGE_CANDIDATE_REGEX).select.with_index do |_part, idx|
|
102
102
|
idx.odd?
|
@@ -112,7 +112,7 @@ module HTMLProofer
|
|
112
112
|
end
|
113
113
|
|
114
114
|
def srcsets_wo_sizes
|
115
|
-
return
|
115
|
+
return if blank?(srcsets)
|
116
116
|
|
117
117
|
srcsets.map do |srcset|
|
118
118
|
srcset.split(" ").first
|
@@ -133,7 +133,7 @@ module HTMLProofer
|
|
133
133
|
|
134
134
|
attrs = @runner.options[:swap_attributes][@node.name]
|
135
135
|
|
136
|
-
|
136
|
+
true unless blank?(attrs)
|
137
137
|
end
|
138
138
|
|
139
139
|
private def swap_attributes!
|
data/lib/html_proofer/log.rb
CHANGED
@@ -13,7 +13,7 @@ module HTMLProofer
|
|
13
13
|
def initialize(log_level)
|
14
14
|
@logger = Yell.new(
|
15
15
|
format: false,
|
16
|
-
name: "HTMLProofer",
|
16
|
+
name: "HTMLProofer",
|
17
17
|
level: "gte.#{log_level}",
|
18
18
|
) do |l|
|
19
19
|
l.adapter(:stdout, level: "lte.warn")
|
@@ -41,8 +41,8 @@ module HTMLProofer
|
|
41
41
|
:red
|
42
42
|
end
|
43
43
|
|
44
|
-
if
|
45
|
-
|
44
|
+
if STDOUT_LEVELS.include?(level) ||
|
45
|
+
STDERR_LEVELS.include?(level)
|
46
46
|
Rainbow(message).send(color)
|
47
47
|
else
|
48
48
|
message
|
data/lib/html_proofer/runner.rb
CHANGED
@@ -236,7 +236,7 @@ module HTMLProofer
|
|
236
236
|
end
|
237
237
|
|
238
238
|
private def load_cache(type)
|
239
|
-
ivar = instance_variable_get("@#{type}_urls")
|
239
|
+
ivar = instance_variable_get(:"@#{type}_urls")
|
240
240
|
|
241
241
|
existing_urls_count = @cache.size(type)
|
242
242
|
cache_text = pluralize(existing_urls_count, "#{type} link", "#{type} links")
|
@@ -249,7 +249,7 @@ module HTMLProofer
|
|
249
249
|
|
250
250
|
private def format_checks_list(checks)
|
251
251
|
checks.map do |check|
|
252
|
-
check.sub(
|
252
|
+
check.sub("HTMLProofer::Check::", "")
|
253
253
|
end.sort.join(", ")
|
254
254
|
end
|
255
255
|
end
|
@@ -120,9 +120,7 @@ module HTMLProofer
|
|
120
120
|
decoded_href_hash = Addressable::URI.unescape(href_hash)
|
121
121
|
fragment_ids = [href_hash, decoded_href_hash]
|
122
122
|
# https://www.w3.org/TR/html5/single-page.html#scroll-to-fragid
|
123
|
-
|
124
|
-
|
125
|
-
nil
|
123
|
+
true if fragment_ids.include?("top")
|
126
124
|
end
|
127
125
|
|
128
126
|
private def hash_exists_in_html?(href_hash, html)
|
data/lib/html_proofer/version.rb
CHANGED
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.
|
4
|
+
version: 5.0.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Garen Torikian
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-02-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|
@@ -212,7 +212,7 @@ licenses:
|
|
212
212
|
metadata:
|
213
213
|
funding_uri: https://github.com/sponsors/gjtorikian/
|
214
214
|
rubygems_mfa_required: 'true'
|
215
|
-
post_install_message:
|
215
|
+
post_install_message:
|
216
216
|
rdoc_options: []
|
217
217
|
require_paths:
|
218
218
|
- lib
|
@@ -230,8 +230,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
230
230
|
- !ruby/object:Gem::Version
|
231
231
|
version: '0'
|
232
232
|
requirements: []
|
233
|
-
rubygems_version: 3.
|
234
|
-
signing_key:
|
233
|
+
rubygems_version: 3.5.3
|
234
|
+
signing_key:
|
235
235
|
specification_version: 4
|
236
236
|
summary: A set of tests to validate your HTML output. These tests check if your image
|
237
237
|
references are legitimate, if they have alt tags, if your internal links are working,
|