html-proofer 3.0.6 → 3.1.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
  SHA1:
3
- metadata.gz: b26505bd1c7a6f0632a95f2bb1718ae9e2bae90f
4
- data.tar.gz: c8cbb29407b3eedcd997f8e9226323c6e4a55dc3
3
+ metadata.gz: 2d69ea6f2eb74095372c3f46f5b0b40beb25d4c2
4
+ data.tar.gz: b788331194e898263a88a47f41c60f77a4f3051a
5
5
  SHA512:
6
- metadata.gz: 1432ff5ff5ad2c0eeb1ef40b66f46608f0d737e39474f2e8185614ca6ede77af17fd4dd1893fa86fa12bf2c6f9c2c12b19a5713044b99cc705f2a43e236e57be
7
- data.tar.gz: 0f1a23a1534ef863223808efb54dcb493ebb04a51a1793fd25f3875d89e891a19e8beea085791947bee5791a93baa68f4dc2048406acc71b822477b28cef7d6a
6
+ metadata.gz: a98a1fd90173d4481caae3c2fa7b702e1d5ab04cd262f4c555d250b7ce4518e29bcb0f3cfba7cd33d88526389bd05f3665b3ebb6ca0a46404057fa01f7663c62
7
+ data.tar.gz: 603de7c0256dde6120f0cce01e4803768c09468c620a04d81d6b053bd3d66e72573bc8fbe33efa9597a090fcd3c9f8744826021829e1619fc35fdc584c8c7513
data/bin/htmlproofer CHANGED
@@ -18,9 +18,10 @@ Mercenary.program(:htmlproofer) do |p|
18
18
  p.option 'alt_ignore', '--alt-ignore image1,[image2,...]', Array, 'A comma-separated list of Strings or RegExps containing `img`s whose missing `alt` tags are safe to ignore'
19
19
  p.option 'assume_extension', '--assume-extension', 'Automatically add extension (e.g. `.html`) to file paths, to allow extensionless URLs (as supported by Jekyll 3 and GitHub Pages) (default: `false`).'
20
20
  p.option 'checks_to_ignore', '--checks-to-ignore check1,[check2,...]', Array, ' An array of Strings indicating which checks you\'d like to not perform.'
21
- p.option 'check_external_hash', '--check-external-hash', 'Checks whether external hashes exist (even if the website exists). This slows the checker down (default: `false`).'
21
+ p.option 'check_external_hash', '--check-external-hash', 'Checks whether external hashes exist (even if the webpage exists). This slows the checker down (default: `false`).'
22
22
  p.option 'check_favicon', '--check-favicon', 'Enables the favicon checker (default: `false`).'
23
23
  p.option 'check_html', '--check-html', 'Enables HTML validation errors from Nokogiri (default: `false`).'
24
+ p.option 'check_img_http', '--check-img-http', 'Fails an image if it\'s marked as `http` (default: `false`).'
24
25
  p.option 'directory_index_file', '--directory-index-file', String, 'Sets the file to look for when a link refers to a directory. (default: `index.html`)'
25
26
  p.option 'disable_external', '--disable-external', 'If `true`, does not run the external link checker, which can take a lot of time (default: `false`)'
26
27
  p.option 'empty_alt_ignore', '--empty-alt-ignore', 'If `true`, ignores images with empty alt tags'
@@ -37,7 +38,8 @@ Mercenary.program(:htmlproofer) do |p|
37
38
  p.option 'only_4xx', '--only-4xx', 'Only reports errors for links that fall within the 4xx status code range'
38
39
  p.option 'timeframe', '--timeframe <time>', String, 'A string representing the caching timeframe.'
39
40
  p.option 'url_ignore', '--url-ignore link1,[link2,...]', Array, 'A comma-separated list of Strings or RegExps containing URLs that are safe to ignore. It affects all HTML attributes. Note that non-HTTP(S) URIs are always ignored'
40
- p.option 'url_swap', '--url-swap re:string,[re:string,...]', Array, 'A comma-separated list containing key-value pairs of `RegExp => String`. It transforms URLs that match `RegExp` into `String` via `gsub`.'
41
+ p.option 'url_swap', '--url-swap re:string,[re:string,...]', Array, 'A comma-separated list containing key-value pairs of `RegExp => String`. It transforms URLs that match `RegExp` into `String` via `gsub`. The escape sequences `\\:` should be used to produce literal `:`s.'
42
+ p.option 'internal_domains', '--internal-domains domain1,[domain2,...]', Array, 'A comma-separated list of Strings containing domains that will be treated as internal urls.'
41
43
 
42
44
  p.action do |args, opts|
43
45
  args = ['.'] if args.empty?
@@ -47,7 +49,7 @@ Mercenary.program(:htmlproofer) do |p|
47
49
 
48
50
  # prepare everything to go to proofer
49
51
  p.options.select { |o| !opts[o.config_key].nil? }.each do |option|
50
- if option.return_type.to_s == 'Array' # TODO: is_a? doesn't work here?
52
+ if opts[option.config_key].is_a?(Array)
51
53
  opts[option.config_key] = opts[option.config_key].map { |i| HTMLProofer::Configuration.to_regex?(i) }
52
54
  end
53
55
  options[option.config_key.to_sym] = opts[option.config_key]
@@ -57,8 +59,11 @@ Mercenary.program(:htmlproofer) do |p|
57
59
  unless opts['url_swap'].nil?
58
60
  options[:url_swap] = {}
59
61
  opts['url_swap'].each do |s|
60
- pair = s.split(':', 2)
61
- options[:url_swap][Regexp.new(pair[0])] = pair[1]
62
+ splt = s.split(/(?<!\\):/,2)
63
+
64
+ re = splt[0].gsub(/\\:/, ':')
65
+ string = splt[1].gsub(/\\:/, ':')
66
+ options[:url_swap][Regexp.new(re)] = string
62
67
  end
63
68
  end
64
69
 
@@ -73,7 +78,7 @@ Mercenary.program(:htmlproofer) do |p|
73
78
 
74
79
  options[:cache] = {}
75
80
  options[:cache][:timeframe] = opts['timeframe'] unless opts['timeframe'].nil?
76
-
81
+
77
82
  options[:http_status_ignore] = Array(options[:http_status_ignore]).map(&:to_i)
78
83
 
79
84
  paths = path.split(',')
@@ -40,6 +40,10 @@ class ImageCheck < ::HTMLProofer::Check
40
40
  if !@img.ignore_alt? && (@img.alt.nil? || (empty_alt_tag? && !@img.ignore_empty_alt?))
41
41
  add_issue("image #{@img.url} does not have an alt attribute", line: line)
42
42
  end
43
+
44
+ if @img.check_img_http? && @img.scheme == 'http'
45
+ add_issue("image #{@img.url} uses the http scheme", line: line)
46
+ end
43
47
  end
44
48
 
45
49
  external_urls
@@ -9,6 +9,7 @@ module HTMLProofer
9
9
  :check_external_hash => false,
10
10
  :check_favicon => false,
11
11
  :check_html => false,
12
+ :check_img_http => false,
12
13
  :checks_to_ignore => [],
13
14
  :directory_index_file => 'index.html',
14
15
  :disable_external => false,
@@ -19,10 +20,11 @@ module HTMLProofer
19
20
  :external_only => false,
20
21
  :file_ignore => [],
21
22
  :http_status_ignore => [],
23
+ :internal_domains => [],
22
24
  :log_level => :info,
23
25
  :only_4xx => false,
24
26
  :url_ignore => [],
25
- :url_swap => []
27
+ :url_swap => {}
26
28
  }
27
29
 
28
30
  TYPHOEUS_DEFAULTS = {
@@ -9,7 +9,7 @@ module HTMLProofer
9
9
  attr_reader :id, :name, :alt, :href, :link, :src, :line, :data_proofer_ignore
10
10
 
11
11
  def initialize(obj, check)
12
- # Contruct readable ivars for every element
12
+ # Construct readable ivars for every element
13
13
  obj.attributes.each_pair do |attribute, value|
14
14
  name = "#{attribute.tr('-:.', '_')}".to_sym
15
15
  (class << self; self; end).send(:attr_reader, name)
@@ -91,6 +91,10 @@ module HTMLProofer
91
91
  @check.options[:allow_hash_href]
92
92
  end
93
93
 
94
+ def check_img_http?
95
+ @check.options[:check_img_http]
96
+ end
97
+
94
98
  # path is external to the file
95
99
  def external?
96
100
  !internal?
@@ -23,6 +23,15 @@ module HTMLProofer
23
23
  FileUtils.mkdir_p(STORAGE_DIR)
24
24
  end
25
25
 
26
+ # Add swap patterns for internal domains
27
+ unless @options[:internal_domains].empty?
28
+ @options[:internal_domains].each do |dom|
29
+ @options[:url_swap][Regexp.new("^http://#{dom}")] = ''
30
+ @options[:url_swap][Regexp.new("^https://#{dom}")] = ''
31
+ @options[:url_swap][Regexp.new("^//#{dom}")] = ''
32
+ end
33
+ end
34
+
26
35
  @failures = []
27
36
  end
28
37
 
@@ -1,3 +1,3 @@
1
1
  module HTMLProofer
2
- VERSION = '3.0.6'
2
+ VERSION = '3.1.0'.freeze
3
3
  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: 3.0.6
4
+ version: 3.1.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: 2016-05-17 00:00:00.000000000 Z
11
+ date: 2016-09-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mercenary
@@ -112,16 +112,22 @@ dependencies:
112
112
  name: activesupport
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - "~>"
115
+ - - ">="
116
116
  - !ruby/object:Gem::Version
117
117
  version: '4.2'
118
+ - - "<"
119
+ - !ruby/object:Gem::Version
120
+ version: '6.0'
118
121
  type: :runtime
119
122
  prerelease: false
120
123
  version_requirements: !ruby/object:Gem::Requirement
121
124
  requirements:
122
- - - "~>"
125
+ - - ">="
123
126
  - !ruby/object:Gem::Version
124
127
  version: '4.2'
128
+ - - "<"
129
+ - !ruby/object:Gem::Version
130
+ version: '6.0'
125
131
  - !ruby/object:Gem::Dependency
126
132
  name: redcarpet
127
133
  requirement: !ruby/object:Gem::Requirement