theme-check 0.10.1 → 0.10.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/Rakefile +1 -1
- data/config/default.yml +4 -0
- data/docs/checks/html_parsing_error.md +50 -0
- data/lib/theme_check/checks/html_parsing_error.rb +12 -0
- data/lib/theme_check/html_visitor.rb +3 -1
- data/lib/theme_check/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dc5f5b1f71dce3de919836a4b8cd55e2ae3994e12c8118a69050840fac21b0e6
|
4
|
+
data.tar.gz: bc190dcdae4c5ec62b8d3e9a6d0a3d1c9ea6fc9b052e843455faf1ed1fc0d92d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 24724968d6b6f792e522289b3a62e200d5a2dc568286f8b5044a4b72253bfeb54aafae140dff38d2bfa9e5cb871d1f65c5c575661bb5b5132f73c36919e1b4f1
|
7
|
+
data.tar.gz: aaf053c7dbe25615daadaef936f58435e84180664b03b9f77edf7eee247581ef6b3ddadcf04816922e738db047693e1ca75a6e5bcfec139d42d2d3c0595fe49c
|
data/CHANGELOG.md
CHANGED
data/Rakefile
CHANGED
data/config/default.yml
CHANGED
@@ -0,0 +1,50 @@
|
|
1
|
+
# Report HTML parsing errors (`HtmlParsingError`)
|
2
|
+
|
3
|
+
Report errors preventing the HTML from being parsed and analyzed by Theme Check.
|
4
|
+
|
5
|
+
## Check Details
|
6
|
+
|
7
|
+
This check is aimed at reporting HTML errors that prevent a file from being analyzed.
|
8
|
+
|
9
|
+
The HTML parser limits the number of attributes per element to 400, and the maximum depth of the DOM tree to 400 levels. If any one of those limits is reached, parsing stops, and all HTML offenses on this file are ignored.
|
10
|
+
|
11
|
+
:-1: Examples of **incorrect** code for this check:
|
12
|
+
|
13
|
+
```liquid
|
14
|
+
<img src="muffin.jpeg"
|
15
|
+
data-attrbute-1=""
|
16
|
+
data-attrbute-2=""
|
17
|
+
... up to
|
18
|
+
data-attrbute-400="">
|
19
|
+
```
|
20
|
+
|
21
|
+
:+1: Examples of **correct** code for this check:
|
22
|
+
|
23
|
+
```liquid
|
24
|
+
<img src="muffin.jpeg">
|
25
|
+
```
|
26
|
+
|
27
|
+
## Check Options
|
28
|
+
|
29
|
+
The default configuration for this check is the following:
|
30
|
+
|
31
|
+
```yaml
|
32
|
+
HtmlParsingError:
|
33
|
+
enabled: true
|
34
|
+
```
|
35
|
+
|
36
|
+
## When Not To Use It
|
37
|
+
|
38
|
+
If you don't care about HTML offenses.
|
39
|
+
|
40
|
+
## Version
|
41
|
+
|
42
|
+
This check has been introduced in Theme Check 0.10.2.
|
43
|
+
|
44
|
+
## Resources
|
45
|
+
|
46
|
+
- [Rule Source][codesource]
|
47
|
+
- [Documentation Source][docsource]
|
48
|
+
|
49
|
+
[codesource]: /lib/theme_check/checks/html_parsing_error.rb
|
50
|
+
[docsource]: /docs/checks/html_parsing_error.md
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module ThemeCheck
|
3
|
+
class HtmlParsingError < HtmlCheck
|
4
|
+
severity :error
|
5
|
+
category :html
|
6
|
+
doc docs_url(__FILE__)
|
7
|
+
|
8
|
+
def on_parse_error(exception, template)
|
9
|
+
add_offense("HTML in this template can not be parsed: #{exception.message}", template: template)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -13,12 +13,14 @@ module ThemeCheck
|
|
13
13
|
def visit_template(template)
|
14
14
|
doc = parse(template)
|
15
15
|
visit(HtmlNode.new(doc, template))
|
16
|
+
rescue ArgumentError => e
|
17
|
+
call_checks(:on_parse_error, e, template)
|
16
18
|
end
|
17
19
|
|
18
20
|
private
|
19
21
|
|
20
22
|
def parse(template)
|
21
|
-
Nokogiri::HTML5.fragment(template.source)
|
23
|
+
Nokogiri::HTML5.fragment(template.source, max_tree_depth: 400, max_attributes: 400)
|
22
24
|
end
|
23
25
|
|
24
26
|
def visit(node)
|
data/lib/theme_check/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: theme-check
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.10.
|
4
|
+
version: 0.10.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marc-André Cournoyer
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-06-
|
11
|
+
date: 2021-06-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: liquid
|
@@ -81,6 +81,7 @@ files:
|
|
81
81
|
- docs/checks/convert_include_to_render.md
|
82
82
|
- docs/checks/default_locale.md
|
83
83
|
- docs/checks/deprecated_filter.md
|
84
|
+
- docs/checks/html_parsing_error.md
|
84
85
|
- docs/checks/img_lazy_loading.md
|
85
86
|
- docs/checks/img_width_and_height.md
|
86
87
|
- docs/checks/liquid_tag.md
|
@@ -123,6 +124,7 @@ files:
|
|
123
124
|
- lib/theme_check/checks/convert_include_to_render.rb
|
124
125
|
- lib/theme_check/checks/default_locale.rb
|
125
126
|
- lib/theme_check/checks/deprecated_filter.rb
|
127
|
+
- lib/theme_check/checks/html_parsing_error.rb
|
126
128
|
- lib/theme_check/checks/img_lazy_loading.rb
|
127
129
|
- lib/theme_check/checks/img_width_and_height.rb
|
128
130
|
- lib/theme_check/checks/liquid_tag.rb
|