html-proofer 4.0.0 → 4.2.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 +4 -4
- data/bin/htmlproofer +4 -1
- data/lib/html_proofer/attribute/url.rb +7 -1
- data/lib/html_proofer/check/images.rb +12 -3
- data/lib/html_proofer/configuration.rb +1 -0
- data/lib/html_proofer/element.rb +22 -0
- data/lib/html_proofer/url_validator/internal.rb +1 -0
- data/lib/html_proofer/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 916656620e369529ae71be63c4316ba627afcf97d2f60b4ce963e375f772a7b8
|
4
|
+
data.tar.gz: 83e751f1ec8bf453c2612cf1d34ef24e3de1d7620d740be1f8c392627f39cc85
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c396512e2262ba0bbeab69ee602c42c522cdec4f7b9036e81808011e4b6d47e06188baeaa86524361166af90ce1751b3f08e4075b437b28eab8c4c6bec065630
|
7
|
+
data.tar.gz: e2e660641cca01f1501b69dda405808624ec03b4ebaa0a9c12618f82e77314f94adbc459ec343898f548be5676f763d11d69bf5cbbebf154148490e49b304f83
|
data/bin/htmlproofer
CHANGED
@@ -21,10 +21,11 @@ Mercenary.program(:htmlproofer) do |p|
|
|
21
21
|
p.option 'assume_extension', '--assume-extension <ext>', 'Automatically add specified extension to files for internal links, to allow extensionless URLs (as supported by most servers) (default: `.html`).'
|
22
22
|
p.option 'checks', '--checks check1,[check2,...]', Array, 'A comma-separated list of Strings indicating which checks you want to run (default: `["Links", "Images", "Scripts"]`)'
|
23
23
|
p.option 'check_external_hash', '--check-external-hash', 'Checks whether external hashes exist (even if the webpage exists) (default: `true`).'
|
24
|
+
p.option 'check_internal_hash', '--check-internal-hash', 'Checks whether internal hashes exist (even if the webpage exists) (default: `true`).'
|
24
25
|
p.option 'check_sri', '--check-sri', 'Check that `<link>` and `<script>` external resources use SRI (default: `false`).'
|
25
26
|
p.option 'directory_index_file', '--directory-index-file <filename>', String, 'Sets the file to look for when a link refers to a directory. (default: `index.html`)'
|
26
27
|
p.option 'disable_external', '--disable-external', 'If `true`, does not run the external link checker (default: `false`)'
|
27
|
-
p.option 'enforce_https', '--enforce-https', 'Fails a link if it\'s not marked as `https` (default: `true`).'
|
28
|
+
p.option 'enforce_https', '--enforce-https <false>', String, 'Fails a link if it\'s not marked as `https` (default: `true`).'
|
28
29
|
p.option 'extensions', '--extensions ext1,[ext2,...[', Array, 'A comma-separated list of Strings indicating the file extensions you would like to check (including the dot) (default: `.html`)'
|
29
30
|
p.option 'ignore_empty_alt', '--ignore-empty-alt', ' If `true`, ignores images with empty/missing alt tags (in other words, `<img alt>` and `<img alt="">` are valid; set this to `false` to flag those)'
|
30
31
|
p.option 'ignore_files', '--ignore-files file1,[file2,...]', Array, 'A comma-separated list of Strings or RegExps containing file paths that are safe to ignore'
|
@@ -67,6 +68,8 @@ Mercenary.program(:htmlproofer) do |p|
|
|
67
68
|
end
|
68
69
|
end
|
69
70
|
|
71
|
+
options[:enforce_https] = false if opts['enforce_https'] == "false"
|
72
|
+
|
70
73
|
options[:log_level] = opts['log_level'].to_sym unless opts['log_level'].nil?
|
71
74
|
|
72
75
|
options[:typhoeus] = HTMLProofer::Configuration.parse_json_option('typhoeus', opts['typhoeus'], symbolize_names: false) unless opts['typhoeus'].nil?
|
@@ -161,7 +161,13 @@ module HTMLProofer
|
|
161
161
|
end
|
162
162
|
|
163
163
|
def unslashed_directory?(file)
|
164
|
-
File.directory?(file)
|
164
|
+
return false unless File.directory?(file)
|
165
|
+
|
166
|
+
!file.end_with?(File::SEPARATOR) && !follow_location?
|
167
|
+
end
|
168
|
+
|
169
|
+
def follow_location?
|
170
|
+
@runner.options[:typhoeus] && @runner.options[:typhoeus][:followlocation]
|
165
171
|
end
|
166
172
|
|
167
173
|
def absolute_path?(path)
|
@@ -20,12 +20,21 @@ module HTMLProofer
|
|
20
20
|
add_failure("image has no src or srcset attribute", line: @img.line, content: @img.content)
|
21
21
|
elsif @img.url.remote?
|
22
22
|
add_to_external_urls(@img.url, @img.line)
|
23
|
-
elsif !@img.url.exists? && !@img.multiple_srcsets?
|
23
|
+
elsif !@img.url.exists? && !@img.multiple_srcsets? && !@img.multiple_sizes?
|
24
24
|
add_failure("internal image #{@img.url.raw_attribute} does not exist", line: @img.line,
|
25
25
|
content: @img.content)
|
26
26
|
elsif @img.multiple_srcsets?
|
27
|
-
srcsets
|
28
|
-
|
27
|
+
@img.srcsets.each do |srcset|
|
28
|
+
srcset_url = HTMLProofer::Attribute::Url.new(@runner, srcset, base_url: @img.base_url)
|
29
|
+
|
30
|
+
if srcset_url.remote?
|
31
|
+
add_to_external_urls(srcset_url.url, @img.line)
|
32
|
+
elsif !srcset_url.exists?
|
33
|
+
add_failure("internal image #{srcset} does not exist", line: @img.line, content: @img.content)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
elsif @img.multiple_sizes?
|
37
|
+
@img.srcsets_wo_sizes.each do |srcset|
|
29
38
|
srcset_url = HTMLProofer::Attribute::Url.new(@runner, srcset, base_url: @img.base_url)
|
30
39
|
|
31
40
|
if srcset_url.remote?
|
data/lib/html_proofer/element.rb
CHANGED
@@ -84,6 +84,28 @@ module HTMLProofer
|
|
84
84
|
!blank?(srcset) && srcset.split(",").size > 1
|
85
85
|
end
|
86
86
|
|
87
|
+
def srcsets
|
88
|
+
return nil if blank?(srcset)
|
89
|
+
|
90
|
+
srcset.split(",").map(&:strip)
|
91
|
+
end
|
92
|
+
|
93
|
+
def multiple_sizes?
|
94
|
+
return false if blank?(srcsets)
|
95
|
+
|
96
|
+
srcsets.any? do |srcset|
|
97
|
+
!blank?(srcset) && srcset.split(" ").size > 1
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
def srcsets_wo_sizes
|
102
|
+
return nil if blank?(srcsets)
|
103
|
+
|
104
|
+
srcsets.map do |srcset|
|
105
|
+
srcset.split(" ").first
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
87
109
|
def ignore?
|
88
110
|
return true if @node.attributes["data-proofer-ignore"]
|
89
111
|
return true if ancestors_ignorable?
|
@@ -68,6 +68,7 @@ module HTMLProofer
|
|
68
68
|
private def hash_exists?(url)
|
69
69
|
href_hash = url.hash
|
70
70
|
return true if blank?(href_hash)
|
71
|
+
return true unless @runner.options[:check_internal_hash]
|
71
72
|
|
72
73
|
# prevents searching files we didn't ask about
|
73
74
|
return false unless url.known_extension?
|
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: 4.
|
4
|
+
version: 4.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Garen Torikian
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-07-
|
11
|
+
date: 2022-07-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|