svg_conform 0.1.0 → 0.1.2
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/.github/workflows/rake.yml +4 -1
- data/.github/workflows/release.yml +6 -2
- data/.rubocop_todo.yml +273 -10
- data/Gemfile +1 -0
- data/README.adoc +54 -37
- data/config/profiles/metanorma.yml +4 -4
- data/docs/remediation.adoc +541 -542
- data/docs/requirements.adoc +800 -357
- data/examples/readme_usage.rb +67 -0
- data/examples/requirements_demo.rb +4 -4
- data/lib/svg_conform/document.rb +7 -1
- data/lib/svg_conform/element_proxy.rb +101 -0
- data/lib/svg_conform/fast_document_analyzer.rb +82 -0
- data/lib/svg_conform/node_index_builder.rb +47 -0
- data/lib/svg_conform/remediations/no_external_css_remediation.rb +4 -4
- data/lib/svg_conform/requirements/allowed_elements_requirement.rb +202 -0
- data/lib/svg_conform/requirements/base_requirement.rb +27 -0
- data/lib/svg_conform/requirements/color_restrictions_requirement.rb +53 -0
- data/lib/svg_conform/requirements/font_family_requirement.rb +18 -0
- data/lib/svg_conform/requirements/forbidden_content_requirement.rb +26 -0
- data/lib/svg_conform/requirements/id_reference_requirement.rb +96 -0
- data/lib/svg_conform/requirements/invalid_id_references_requirement.rb +91 -0
- data/lib/svg_conform/requirements/link_validation_requirement.rb +30 -0
- data/lib/svg_conform/requirements/namespace_attributes_requirement.rb +59 -0
- data/lib/svg_conform/requirements/namespace_requirement.rb +74 -0
- data/lib/svg_conform/requirements/no_external_css_requirement.rb +74 -0
- data/lib/svg_conform/requirements/no_external_fonts_requirement.rb +58 -0
- data/lib/svg_conform/requirements/no_external_images_requirement.rb +40 -0
- data/lib/svg_conform/requirements/style_requirement.rb +12 -0
- data/lib/svg_conform/requirements/viewbox_required_requirement.rb +72 -0
- data/lib/svg_conform/sax_document.rb +46 -0
- data/lib/svg_conform/sax_validation_handler.rb +158 -0
- data/lib/svg_conform/validation_context.rb +84 -2
- data/lib/svg_conform/validator.rb +74 -6
- data/lib/svg_conform/version.rb +1 -1
- data/lib/svg_conform.rb +1 -0
- data/spec/fixtures/namespace/repair/basic_violations.svg +3 -3
- data/spec/fixtures/namespace_attributes/repair/basic_violations.svg +2 -2
- data/spec/fixtures/no_external_css/repair/basic_violations.svg +2 -2
- data/spec/fixtures/style_promotion/repair/basic_test.svg +2 -2
- data/svg_conform.gemspec +1 -1
- metadata +12 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 43ff84b9d1f47a6a2bd92624483c0445bd3f77d29f0fc36f2c02116a40111bc2
|
|
4
|
+
data.tar.gz: be072c8772885cd746ee623e028e00517dfcac93250a00f4015cb7122d94739a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0ee8ad3bfab5a2aec10b32caa23141967aa25112e0393ed39242ab83a5f123bb317190392df347f7f4a8665af61bf7de4b09eb3283c4c140e372af1177ba924b
|
|
7
|
+
data.tar.gz: 20d1871024c131298aa2462bd849e07dfb16b73f2f61913da8f9c2d21b43e87fcfe5ae6ed298971091c0f85734efe8a36790432ccdb18c8878dafc25d238a348
|
data/.github/workflows/rake.yml
CHANGED
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
# See https://github.com/metanorma/cimas
|
|
3
3
|
name: rake
|
|
4
4
|
|
|
5
|
+
permissions:
|
|
6
|
+
contents: write
|
|
7
|
+
|
|
5
8
|
on:
|
|
6
9
|
push:
|
|
7
10
|
branches: [ master, main ]
|
|
@@ -12,4 +15,4 @@ jobs:
|
|
|
12
15
|
rake:
|
|
13
16
|
uses: metanorma/ci/.github/workflows/generic-rake.yml@main
|
|
14
17
|
secrets:
|
|
15
|
-
pat_token: ${{ secrets.
|
|
18
|
+
pat_token: ${{ secrets.GITHUB_TOKEN }}
|
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
# See https://github.com/metanorma/cimas
|
|
3
3
|
name: release
|
|
4
4
|
|
|
5
|
+
permissions:
|
|
6
|
+
contents: write
|
|
7
|
+
packages: write
|
|
8
|
+
|
|
5
9
|
on:
|
|
6
10
|
workflow_dispatch:
|
|
7
11
|
inputs:
|
|
@@ -19,5 +23,5 @@ jobs:
|
|
|
19
23
|
with:
|
|
20
24
|
next_version: ${{ github.event.inputs.next_version }}
|
|
21
25
|
secrets:
|
|
22
|
-
rubygems-api-key: ${{ secrets.
|
|
23
|
-
pat_token: ${{ secrets.
|
|
26
|
+
rubygems-api-key: ${{ secrets.CLARICLE_CI_RUBYGEMS_API_KEY }}
|
|
27
|
+
pat_token: ${{ secrets.GITHUB_TOKEN }}
|
data/.rubocop_todo.yml
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# This configuration was generated by
|
|
2
2
|
# `rubocop --auto-gen-config`
|
|
3
|
-
# on 2025-
|
|
3
|
+
# on 2025-11-18 13:36:55 UTC using RuboCop version 1.81.1.
|
|
4
4
|
# The point is for the user to remove these configuration records
|
|
5
5
|
# one by one as the offenses are removed from the code base.
|
|
6
6
|
# Note that changes in the inspected code, or installation of new
|
|
@@ -14,13 +14,116 @@ Layout/BlockAlignment:
|
|
|
14
14
|
Exclude:
|
|
15
15
|
- 'spec/svg_conform/profiles/svg_1_2_rfc_profile_spec.rb'
|
|
16
16
|
|
|
17
|
-
# Offense count:
|
|
17
|
+
# Offense count: 1
|
|
18
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
19
|
+
# Configuration parameters: AllowForAlignment.
|
|
20
|
+
Layout/CommentIndentation:
|
|
21
|
+
Exclude:
|
|
22
|
+
- 'lib/svg_conform/validation_context.rb'
|
|
23
|
+
|
|
24
|
+
# Offense count: 1
|
|
25
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
26
|
+
Layout/ElseAlignment:
|
|
27
|
+
Exclude:
|
|
28
|
+
- 'lib/svg_conform/requirements/namespace_attributes_requirement.rb'
|
|
29
|
+
|
|
30
|
+
# Offense count: 17
|
|
31
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
32
|
+
Layout/EmptyLineAfterGuardClause:
|
|
33
|
+
Exclude:
|
|
34
|
+
- 'analyze_error_nodes.rb'
|
|
35
|
+
- 'check_duplicates.rb'
|
|
36
|
+
- 'check_position_collisions.rb'
|
|
37
|
+
- 'check_unique_positions.rb'
|
|
38
|
+
- 'compare_errors.rb'
|
|
39
|
+
- 'debug_object_ids.rb'
|
|
40
|
+
- 'debug_utf8.rb'
|
|
41
|
+
- 'find_all_elements.rb'
|
|
42
|
+
- 'find_missing_errors.rb'
|
|
43
|
+
- 'lib/svg_conform/fast_document_analyzer.rb'
|
|
44
|
+
- 'lib/svg_conform/node_index_builder.rb'
|
|
45
|
+
- 'lib/svg_conform/requirements/id_reference_requirement.rb'
|
|
46
|
+
- 'lib/svg_conform/sax_validation_handler.rb'
|
|
47
|
+
|
|
48
|
+
# Offense count: 1
|
|
49
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
50
|
+
# Configuration parameters: EnforcedStyleAlignWith, Severity.
|
|
51
|
+
# SupportedStylesAlignWith: keyword, variable, start_of_line
|
|
52
|
+
Layout/EndAlignment:
|
|
53
|
+
Exclude:
|
|
54
|
+
- 'lib/svg_conform/requirements/namespace_attributes_requirement.rb'
|
|
55
|
+
|
|
56
|
+
# Offense count: 21
|
|
57
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
58
|
+
# Configuration parameters: AllowForAlignment, AllowBeforeTrailingComments, ForceEqualSignAlignment.
|
|
59
|
+
Layout/ExtraSpacing:
|
|
60
|
+
Exclude:
|
|
61
|
+
- 'find_missing_errors.rb'
|
|
62
|
+
- 'lib/svg_conform/element_proxy.rb'
|
|
63
|
+
- 'lib/svg_conform/requirements/id_reference_requirement.rb'
|
|
64
|
+
- 'lib/svg_conform/requirements/invalid_id_references_requirement.rb'
|
|
65
|
+
- 'lib/svg_conform/sax_validation_handler.rb'
|
|
66
|
+
- 'lib/svg_conform/validation_context.rb'
|
|
67
|
+
- 'lib/svg_conform/validator.rb'
|
|
68
|
+
|
|
69
|
+
# Offense count: 1
|
|
70
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
71
|
+
Layout/HeredocIndentation:
|
|
72
|
+
Exclude:
|
|
73
|
+
- 'test_sax_basic.rb'
|
|
74
|
+
|
|
75
|
+
# Offense count: 1
|
|
76
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
77
|
+
# Configuration parameters: EnforcedStyle.
|
|
78
|
+
# SupportedStyles: normal, indented_internal_methods
|
|
79
|
+
Layout/IndentationConsistency:
|
|
80
|
+
Exclude:
|
|
81
|
+
- 'lib/svg_conform/validation_context.rb'
|
|
82
|
+
|
|
83
|
+
# Offense count: 1
|
|
84
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
85
|
+
# Configuration parameters: Width, AllowedPatterns.
|
|
86
|
+
Layout/IndentationWidth:
|
|
87
|
+
Exclude:
|
|
88
|
+
- 'lib/svg_conform/requirements/namespace_attributes_requirement.rb'
|
|
89
|
+
|
|
90
|
+
# Offense count: 604
|
|
18
91
|
# This cop supports safe autocorrection (--autocorrect).
|
|
19
92
|
# Configuration parameters: Max, AllowHeredoc, AllowURI, AllowQualifiedName, URISchemes, IgnoreCopDirectives, AllowedPatterns, SplitStrings.
|
|
20
93
|
# URISchemes: http, https
|
|
21
94
|
Layout/LineLength:
|
|
22
95
|
Enabled: false
|
|
23
96
|
|
|
97
|
+
# Offense count: 28
|
|
98
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
99
|
+
# Configuration parameters: AllowForAlignment, EnforcedStyleForExponentOperator, EnforcedStyleForRationalLiterals.
|
|
100
|
+
# SupportedStylesForExponentOperator: space, no_space
|
|
101
|
+
# SupportedStylesForRationalLiterals: space, no_space
|
|
102
|
+
Layout/SpaceAroundOperators:
|
|
103
|
+
Exclude:
|
|
104
|
+
- 'benchmark_sax.rb'
|
|
105
|
+
- 'benchmark_validation.rb'
|
|
106
|
+
- 'check_clippath_font.rb'
|
|
107
|
+
- 'check_unique_positions.rb'
|
|
108
|
+
- 'count_elements.rb'
|
|
109
|
+
- 'final_demo.rb'
|
|
110
|
+
- 'test_remediation.rb'
|
|
111
|
+
|
|
112
|
+
# Offense count: 32
|
|
113
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
114
|
+
# Configuration parameters: AllowInHeredoc.
|
|
115
|
+
Layout/TrailingWhitespace:
|
|
116
|
+
Exclude:
|
|
117
|
+
- 'analyze_error_nodes.rb'
|
|
118
|
+
- 'check_clippath_font.rb'
|
|
119
|
+
- 'debug_positions.rb'
|
|
120
|
+
- 'debug_utf8.rb'
|
|
121
|
+
- 'final_demo.rb'
|
|
122
|
+
- 'find_missing_errors.rb'
|
|
123
|
+
- 'lib/svg_conform/fast_document_analyzer.rb'
|
|
124
|
+
- 'lib/svg_conform/sax_document.rb'
|
|
125
|
+
- 'test_sax_basic.rb'
|
|
126
|
+
|
|
24
127
|
# Offense count: 2
|
|
25
128
|
# Configuration parameters: AllowedMethods.
|
|
26
129
|
# AllowedMethods: enums
|
|
@@ -28,7 +131,7 @@ Lint/ConstantDefinitionInBlock:
|
|
|
28
131
|
Exclude:
|
|
29
132
|
- 'spec/svg_conform/profiles/svg_1_2_rfc_profile_spec.rb'
|
|
30
133
|
|
|
31
|
-
# Offense count:
|
|
134
|
+
# Offense count: 19
|
|
32
135
|
# Configuration parameters: IgnoreLiteralBranches, IgnoreConstantBranches, IgnoreDuplicateElseBranch.
|
|
33
136
|
Lint/DuplicateBranch:
|
|
34
137
|
Exclude:
|
|
@@ -38,30 +141,65 @@ Lint/DuplicateBranch:
|
|
|
38
141
|
- 'lib/svg_conform/semantic_comparator.rb'
|
|
39
142
|
- 'lib/svg_conform/validation_context.rb'
|
|
40
143
|
- 'lib/svg_conform/validation_result.rb'
|
|
144
|
+
- 'lib/svg_conform/validator.rb'
|
|
41
145
|
|
|
42
146
|
# Offense count: 2
|
|
43
147
|
Lint/DuplicateCaseCondition:
|
|
44
148
|
Exclude:
|
|
45
149
|
- 'lib/svg_conform/semantic_comparator.rb'
|
|
46
150
|
|
|
47
|
-
# Offense count:
|
|
151
|
+
# Offense count: 2
|
|
48
152
|
Lint/DuplicateMethods:
|
|
49
153
|
Exclude:
|
|
154
|
+
- 'lib/svg_conform/sax_validation_handler.rb'
|
|
50
155
|
- 'lib/svg_conform/validation_context.rb'
|
|
51
156
|
|
|
52
|
-
# Offense count:
|
|
157
|
+
# Offense count: 1
|
|
158
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
159
|
+
Lint/IdentityComparison:
|
|
160
|
+
Exclude:
|
|
161
|
+
- 'lib/svg_conform/fast_document_analyzer.rb'
|
|
162
|
+
|
|
163
|
+
# Offense count: 4
|
|
53
164
|
# Configuration parameters: AllowedParentClasses.
|
|
54
165
|
Lint/MissingSuper:
|
|
55
166
|
Exclude:
|
|
56
167
|
- 'lib/svg_conform/compatibility/pattern_discovery.rb'
|
|
57
168
|
- 'lib/svg_conform/compatibility/validity_analysis.rb'
|
|
169
|
+
- 'lib/svg_conform/sax_validation_handler.rb'
|
|
170
|
+
|
|
171
|
+
# Offense count: 3
|
|
172
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
173
|
+
Lint/ScriptPermission:
|
|
174
|
+
Exclude:
|
|
175
|
+
- 'benchmark_validation.rb'
|
|
176
|
+
- 'final_demo.rb'
|
|
177
|
+
- 'test_remediation.rb'
|
|
58
178
|
|
|
59
179
|
# Offense count: 1
|
|
60
180
|
Lint/UnreachableCode:
|
|
61
181
|
Exclude:
|
|
62
182
|
- 'lib/svg_conform/commands/check.rb'
|
|
63
183
|
|
|
64
|
-
# Offense count:
|
|
184
|
+
# Offense count: 4
|
|
185
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
186
|
+
# Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods, IgnoreNotImplementedMethods, NotImplementedExceptions.
|
|
187
|
+
# NotImplementedExceptions: NotImplementedError
|
|
188
|
+
Lint/UnusedMethodArgument:
|
|
189
|
+
Exclude:
|
|
190
|
+
- 'lib/svg_conform/element_proxy.rb'
|
|
191
|
+
- 'lib/svg_conform/requirements/id_reference_requirement.rb'
|
|
192
|
+
- 'lib/svg_conform/requirements/invalid_id_references_requirement.rb'
|
|
193
|
+
- 'lib/svg_conform/sax_validation_handler.rb'
|
|
194
|
+
|
|
195
|
+
# Offense count: 1
|
|
196
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
197
|
+
# Configuration parameters: ContextCreatingMethods, MethodCreatingMethods.
|
|
198
|
+
Lint/UselessAccessModifier:
|
|
199
|
+
Exclude:
|
|
200
|
+
- 'lib/svg_conform/requirements/namespace_attributes_requirement.rb'
|
|
201
|
+
|
|
202
|
+
# Offense count: 147
|
|
65
203
|
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes, Max.
|
|
66
204
|
Metrics/AbcSize:
|
|
67
205
|
Enabled: false
|
|
@@ -72,17 +210,17 @@ Metrics/AbcSize:
|
|
|
72
210
|
Metrics/BlockLength:
|
|
73
211
|
Max: 253
|
|
74
212
|
|
|
75
|
-
# Offense count:
|
|
213
|
+
# Offense count: 8
|
|
76
214
|
# Configuration parameters: CountBlocks, CountModifierForms.
|
|
77
215
|
Metrics/BlockNesting:
|
|
78
216
|
Max: 4
|
|
79
217
|
|
|
80
|
-
# Offense count:
|
|
218
|
+
# Offense count: 125
|
|
81
219
|
# Configuration parameters: AllowedMethods, AllowedPatterns, Max.
|
|
82
220
|
Metrics/CyclomaticComplexity:
|
|
83
221
|
Enabled: false
|
|
84
222
|
|
|
85
|
-
# Offense count:
|
|
223
|
+
# Offense count: 257
|
|
86
224
|
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
|
|
87
225
|
Metrics/MethodLength:
|
|
88
226
|
Max: 154
|
|
@@ -92,11 +230,18 @@ Metrics/MethodLength:
|
|
|
92
230
|
Metrics/ParameterLists:
|
|
93
231
|
Max: 9
|
|
94
232
|
|
|
95
|
-
# Offense count:
|
|
233
|
+
# Offense count: 101
|
|
96
234
|
# Configuration parameters: AllowedMethods, AllowedPatterns, Max.
|
|
97
235
|
Metrics/PerceivedComplexity:
|
|
98
236
|
Enabled: false
|
|
99
237
|
|
|
238
|
+
# Offense count: 4
|
|
239
|
+
# Configuration parameters: EnforcedStyle, AllowedIdentifiers, AllowedPatterns, ForbiddenIdentifiers, ForbiddenPatterns.
|
|
240
|
+
# SupportedStyles: snake_case, camelCase
|
|
241
|
+
Naming/VariableName:
|
|
242
|
+
Exclude:
|
|
243
|
+
- 'check_clippath_font.rb'
|
|
244
|
+
|
|
100
245
|
# Offense count: 2
|
|
101
246
|
# Configuration parameters: MinSize.
|
|
102
247
|
Performance/CollectionLiteralInLoop:
|
|
@@ -104,6 +249,12 @@ Performance/CollectionLiteralInLoop:
|
|
|
104
249
|
- 'lib/svg_conform/batch_report.rb'
|
|
105
250
|
- 'lib/svg_conform/compatibility/pattern_discovery.rb'
|
|
106
251
|
|
|
252
|
+
# Offense count: 1
|
|
253
|
+
# This cop supports unsafe autocorrection (--autocorrect-all).
|
|
254
|
+
Performance/UnfreezeString:
|
|
255
|
+
Exclude:
|
|
256
|
+
- 'lib/svg_conform/element_proxy.rb'
|
|
257
|
+
|
|
107
258
|
# Offense count: 8
|
|
108
259
|
# Configuration parameters: IgnoredMetadata.
|
|
109
260
|
RSpec/DescribeClass:
|
|
@@ -146,6 +297,14 @@ Rake/MethodDefinitionInTask:
|
|
|
146
297
|
Exclude:
|
|
147
298
|
- 'lib/tasks/svgcheck.rake'
|
|
148
299
|
|
|
300
|
+
# Offense count: 3
|
|
301
|
+
# This cop supports unsafe autocorrection (--autocorrect-all).
|
|
302
|
+
Style/CombinableLoops:
|
|
303
|
+
Exclude:
|
|
304
|
+
- 'check_duplicates.rb'
|
|
305
|
+
- 'compare_errors.rb'
|
|
306
|
+
- 'find_missing_errors.rb'
|
|
307
|
+
|
|
149
308
|
# Offense count: 2
|
|
150
309
|
# This cop supports safe autocorrection (--autocorrect).
|
|
151
310
|
# Configuration parameters: EnforcedStyle, AllowComments.
|
|
@@ -167,6 +326,19 @@ Style/MissingRespondToMissing:
|
|
|
167
326
|
Exclude:
|
|
168
327
|
- 'lib/svg_conform/cli.rb'
|
|
169
328
|
|
|
329
|
+
# Offense count: 6
|
|
330
|
+
# This cop supports unsafe autocorrection (--autocorrect-all).
|
|
331
|
+
# Configuration parameters: EnforcedStyle, AllowedMethods, AllowedPatterns.
|
|
332
|
+
# SupportedStyles: predicate, comparison
|
|
333
|
+
Style/NumericPredicate:
|
|
334
|
+
Exclude:
|
|
335
|
+
- 'spec/**/*'
|
|
336
|
+
- 'benchmark_validation.rb'
|
|
337
|
+
- 'check_unique_positions.rb'
|
|
338
|
+
- 'lib/svg_conform/validation_context.rb'
|
|
339
|
+
- 'test_remediation.rb'
|
|
340
|
+
- 'test_sax_basic.rb'
|
|
341
|
+
|
|
170
342
|
# Offense count: 4
|
|
171
343
|
# Configuration parameters: AllowedMethods.
|
|
172
344
|
# AllowedMethods: respond_to_missing?
|
|
@@ -174,6 +346,12 @@ Style/OptionalBooleanParameter:
|
|
|
174
346
|
Exclude:
|
|
175
347
|
- 'lib/svg_conform/semantic_comparator.rb'
|
|
176
348
|
|
|
349
|
+
# Offense count: 1
|
|
350
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
351
|
+
Style/RedundantAssignment:
|
|
352
|
+
Exclude:
|
|
353
|
+
- 'lib/svg_conform/fast_document_analyzer.rb'
|
|
354
|
+
|
|
177
355
|
# Offense count: 1
|
|
178
356
|
# This cop supports safe autocorrection (--autocorrect).
|
|
179
357
|
# Configuration parameters: AllowedMethods.
|
|
@@ -181,3 +359,88 @@ Style/OptionalBooleanParameter:
|
|
|
181
359
|
Style/RedundantCondition:
|
|
182
360
|
Exclude:
|
|
183
361
|
- 'lib/svg_conform/external_checkers/svgcheck/parser.rb'
|
|
362
|
+
|
|
363
|
+
# Offense count: 1
|
|
364
|
+
# This cop supports unsafe autocorrection (--autocorrect-all).
|
|
365
|
+
Style/RedundantInterpolation:
|
|
366
|
+
Exclude:
|
|
367
|
+
- 'analyze_error_nodes.rb'
|
|
368
|
+
|
|
369
|
+
# Offense count: 2
|
|
370
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
371
|
+
# Configuration parameters: EnforcedStyle.
|
|
372
|
+
# SupportedStyles: implicit, explicit
|
|
373
|
+
Style/RescueStandardError:
|
|
374
|
+
Exclude:
|
|
375
|
+
- 'debug_node_coverage.rb'
|
|
376
|
+
- 'test_sax_basic.rb'
|
|
377
|
+
|
|
378
|
+
# Offense count: 3
|
|
379
|
+
# This cop supports unsafe autocorrection (--autocorrect-all).
|
|
380
|
+
# Configuration parameters: ConvertCodeThatCanStartToReturnNil, AllowedMethods, MaxChainLength.
|
|
381
|
+
# AllowedMethods: present?, blank?, presence, try, try!
|
|
382
|
+
Style/SafeNavigation:
|
|
383
|
+
Exclude:
|
|
384
|
+
- 'count_elements.rb'
|
|
385
|
+
- 'lib/svg_conform/fast_document_analyzer.rb'
|
|
386
|
+
|
|
387
|
+
# Offense count: 4
|
|
388
|
+
# This cop supports unsafe autocorrection (--autocorrect-all).
|
|
389
|
+
# Configuration parameters: Mode.
|
|
390
|
+
Style/StringConcatenation:
|
|
391
|
+
Exclude:
|
|
392
|
+
- 'benchmark_sax.rb'
|
|
393
|
+
- 'benchmark_validation.rb'
|
|
394
|
+
- 'final_demo.rb'
|
|
395
|
+
- 'test_remediation.rb'
|
|
396
|
+
|
|
397
|
+
# Offense count: 78
|
|
398
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
399
|
+
# Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline.
|
|
400
|
+
# SupportedStyles: single_quotes, double_quotes
|
|
401
|
+
Style/StringLiterals:
|
|
402
|
+
Enabled: false
|
|
403
|
+
|
|
404
|
+
# Offense count: 34
|
|
405
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
406
|
+
# Configuration parameters: EnforcedStyleForMultiline.
|
|
407
|
+
# SupportedStylesForMultiline: comma, consistent_comma, diff_comma, no_comma
|
|
408
|
+
Style/TrailingCommaInArguments:
|
|
409
|
+
Exclude:
|
|
410
|
+
- 'lib/svg_conform/requirements/allowed_elements_requirement.rb'
|
|
411
|
+
- 'lib/svg_conform/requirements/color_restrictions_requirement.rb'
|
|
412
|
+
- 'lib/svg_conform/requirements/font_family_requirement.rb'
|
|
413
|
+
- 'lib/svg_conform/requirements/forbidden_content_requirement.rb'
|
|
414
|
+
- 'lib/svg_conform/requirements/id_reference_requirement.rb'
|
|
415
|
+
- 'lib/svg_conform/requirements/invalid_id_references_requirement.rb'
|
|
416
|
+
- 'lib/svg_conform/requirements/link_validation_requirement.rb'
|
|
417
|
+
- 'lib/svg_conform/requirements/namespace_attributes_requirement.rb'
|
|
418
|
+
- 'lib/svg_conform/requirements/namespace_requirement.rb'
|
|
419
|
+
- 'lib/svg_conform/requirements/no_external_css_requirement.rb'
|
|
420
|
+
- 'lib/svg_conform/requirements/no_external_fonts_requirement.rb'
|
|
421
|
+
- 'lib/svg_conform/requirements/no_external_images_requirement.rb'
|
|
422
|
+
- 'lib/svg_conform/requirements/viewbox_required_requirement.rb'
|
|
423
|
+
- 'lib/svg_conform/sax_validation_handler.rb'
|
|
424
|
+
- 'lib/svg_conform/validator.rb'
|
|
425
|
+
|
|
426
|
+
# Offense count: 12
|
|
427
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
428
|
+
# Configuration parameters: EnforcedStyleForMultiline.
|
|
429
|
+
# SupportedStylesForMultiline: comma, consistent_comma, diff_comma, no_comma
|
|
430
|
+
Style/TrailingCommaInHashLiteral:
|
|
431
|
+
Exclude:
|
|
432
|
+
- 'debug_positions.rb'
|
|
433
|
+
- 'lib/svg_conform/requirements/allowed_elements_requirement.rb'
|
|
434
|
+
- 'lib/svg_conform/requirements/color_restrictions_requirement.rb'
|
|
435
|
+
- 'lib/svg_conform/requirements/namespace_requirement.rb'
|
|
436
|
+
- 'lib/svg_conform/requirements/viewbox_required_requirement.rb'
|
|
437
|
+
- 'lib/svg_conform/validator.rb'
|
|
438
|
+
|
|
439
|
+
# Offense count: 4
|
|
440
|
+
# This cop supports unsafe autocorrection (--autocorrect-all).
|
|
441
|
+
Style/ZeroLengthPredicate:
|
|
442
|
+
Exclude:
|
|
443
|
+
- 'benchmark_validation.rb'
|
|
444
|
+
- 'lib/svg_conform/validation_context.rb'
|
|
445
|
+
- 'test_remediation.rb'
|
|
446
|
+
- 'test_sax_basic.rb'
|
data/Gemfile
CHANGED
data/README.adoc
CHANGED
|
@@ -212,7 +212,7 @@ Details and examples of Ruby API usage can be found in
|
|
|
212
212
|
require 'svg_conform'
|
|
213
213
|
|
|
214
214
|
# Load a profile and validate
|
|
215
|
-
profile = SvgConform::
|
|
215
|
+
profile = SvgConform::Profiles.get(:svg_1_2_rfc)
|
|
216
216
|
document = SvgConform::Document.new(svg_content)
|
|
217
217
|
result = profile.validate(document)
|
|
218
218
|
|
|
@@ -221,11 +221,10 @@ puts "Errors: #{result.errors.count}"
|
|
|
221
221
|
puts "Warnings: #{result.warnings.count}"
|
|
222
222
|
|
|
223
223
|
# Apply remediations to fix issues
|
|
224
|
-
if !result.valid? && profile.
|
|
225
|
-
|
|
226
|
-
remediation_results = engine.apply_remediations(document, result)
|
|
224
|
+
if !result.valid? && profile.remediation_count > 0
|
|
225
|
+
changes = profile.apply_remediations(document)
|
|
227
226
|
|
|
228
|
-
puts "Applied #{
|
|
227
|
+
puts "Applied #{changes.length} remediations"
|
|
229
228
|
puts "Fixed SVG:"
|
|
230
229
|
puts document.to_xml
|
|
231
230
|
end
|
|
@@ -370,55 +369,63 @@ There are two main categories of requirements:
|
|
|
370
369
|
|Type |Requirement |Description
|
|
371
370
|
|
|
372
371
|
|Structural
|
|
373
|
-
|
|
372
|
+
|link:docs/requirements.adoc#namespace-requirement[`NamespaceRequirement`]
|
|
374
373
|
|Ensures proper SVG namespace declarations
|
|
375
374
|
|
|
376
375
|
|Structural
|
|
377
|
-
|
|
376
|
+
|link:docs/requirements.adoc#namespace-attributes-requirement[`NamespaceAttributesRequirement`]
|
|
378
377
|
|Validates namespace attributes are from allowed namespaces
|
|
379
378
|
|
|
380
379
|
|Structural
|
|
381
|
-
|
|
380
|
+
|link:docs/requirements.adoc#allowed-elements-requirement[`AllowedElementsRequirement`]
|
|
382
381
|
|Restricts which SVG elements are permitted
|
|
383
382
|
|
|
384
383
|
|Structural
|
|
385
|
-
|
|
384
|
+
|link:docs/requirements.adoc#viewbox-required-requirement[`ViewboxRequiredRequirement`]
|
|
386
385
|
|Requires viewBox attributes on root elements
|
|
387
386
|
|
|
388
387
|
|Logical
|
|
389
|
-
|
|
388
|
+
|link:docs/requirements.adoc#color-restrictions-requirement[`ColorRestrictionsRequirement`]
|
|
390
389
|
|Enforces color usage restrictions (e.g., grayscale only)
|
|
391
390
|
|
|
392
391
|
|Logical
|
|
393
|
-
|
|
392
|
+
|link:docs/requirements.adoc#font-family-requirement[`FontFamilyRequirement`]
|
|
394
393
|
|Controls font family usage and validates font specifications
|
|
395
394
|
|
|
396
395
|
|Logical
|
|
397
|
-
|
|
396
|
+
|link:docs/requirements.adoc#no-external-css-requirement[`NoExternalCssRequirement`]
|
|
398
397
|
|Prevents external CSS references to ensure self-contained documents
|
|
399
398
|
|
|
400
399
|
|Logical
|
|
401
|
-
|
|
400
|
+
|link:docs/requirements.adoc#no-external-fonts-requirement[`NoExternalFontsRequirement`]
|
|
401
|
+
|Validates that no external font references are present
|
|
402
|
+
|
|
403
|
+
|Logical
|
|
404
|
+
|link:docs/requirements.adoc#no-external-images-requirement[`NoExternalImagesRequirement`]
|
|
405
|
+
|Validates that no external image references are present
|
|
406
|
+
|
|
407
|
+
|Logical
|
|
408
|
+
|link:docs/requirements.adoc#forbidden-content-requirement[`ForbiddenContentRequirement`]
|
|
402
409
|
|Prevents inclusion of forbidden elements and attributes
|
|
403
410
|
|
|
404
411
|
|Logical
|
|
405
|
-
|
|
412
|
+
|link:docs/requirements.adoc#id-reference-requirement[`IdReferenceRequirement`]
|
|
406
413
|
|Validates that ID references point to existing elements
|
|
407
414
|
|
|
408
415
|
|Logical
|
|
409
|
-
|
|
416
|
+
|link:docs/requirements.adoc#invalid-id-references-requirement[`InvalidIdReferencesRequirement`]
|
|
410
417
|
|Detects and validates broken ID references in SVG documents
|
|
411
418
|
|
|
412
419
|
|Logical
|
|
413
|
-
|
|
420
|
+
|link:docs/requirements.adoc#link-validation-requirement[`LinkValidationRequirement`]
|
|
414
421
|
|Validates that links use only ASCII characters (IETF requirement)
|
|
415
422
|
|
|
416
423
|
|Logical
|
|
417
|
-
|
|
424
|
+
|link:docs/requirements.adoc#style-requirement[`StyleRequirement`]
|
|
418
425
|
|Comprehensive CSS style validation including syntax and properties
|
|
419
426
|
|
|
420
427
|
|Logical
|
|
421
|
-
|
|
428
|
+
|link:docs/requirements.adoc#style-promotion-requirement[`StylePromotionRequirement`]
|
|
422
429
|
|Detects style properties that should be promoted to SVG attributes
|
|
423
430
|
|===
|
|
424
431
|
|
|
@@ -438,44 +445,54 @@ SVG documents to resolve requirement violations.
|
|
|
438
445
|
|Type |Remediation |Description |Targets
|
|
439
446
|
|
|
440
447
|
|Content Conversion
|
|
441
|
-
|
|
448
|
+
|link:docs/remediation.adoc#color-remediation[`ColorRemediation`]
|
|
442
449
|
|Converts invalid colors to allowed alternatives using threshold-based conversion
|
|
443
|
-
|
|
450
|
+
|link:docs/requirements.adoc#color-restrictions-requirement[`ColorRestrictionsRequirement`]
|
|
444
451
|
|
|
445
452
|
|Content Conversion
|
|
446
|
-
|
|
453
|
+
|link:docs/remediation.adoc#font-remediation[`FontRemediation`]
|
|
447
454
|
|Maps font families to generic alternatives (serif, sans-serif, monospace)
|
|
448
|
-
|
|
455
|
+
|link:docs/requirements.adoc#font-family-requirement[`FontFamilyRequirement`]
|
|
456
|
+
|
|
457
|
+
|Content Conversion
|
|
458
|
+
|link:docs/remediation.adoc#font-embedding-remediation[`FontEmbeddingRemediation`]
|
|
459
|
+
|Converts external font references to embedded data URIs
|
|
460
|
+
|link:docs/requirements.adoc#no-external-fonts-requirement[`NoExternalFontsRequirement`]
|
|
461
|
+
|
|
462
|
+
|Content Conversion
|
|
463
|
+
|link:docs/remediation.adoc#image-embedding-remediation[`ImageEmbeddingRemediation`]
|
|
464
|
+
|Converts external image references to embedded data URIs
|
|
465
|
+
|link:docs/requirements.adoc#no-external-images-requirement[`NoExternalImagesRequirement`]
|
|
449
466
|
|
|
450
467
|
|Element/Attribute Removal
|
|
451
|
-
|
|
468
|
+
|link:docs/remediation.adoc#namespace-remediation[`NamespaceRemediation`]
|
|
452
469
|
|Removes invalid namespace elements and cleans up namespace declarations
|
|
453
|
-
|
|
470
|
+
|link:docs/requirements.adoc#namespace-requirement[`NamespaceRequirement`]
|
|
454
471
|
|
|
455
472
|
|Element/Attribute Removal
|
|
456
|
-
|
|
473
|
+
|link:docs/remediation.adoc#namespace-attribute-remediation[`NamespaceAttributeRemediation`]
|
|
457
474
|
|Removes attributes from disallowed namespaces
|
|
458
|
-
|
|
475
|
+
|link:docs/requirements.adoc#namespace-attributes-requirement[`NamespaceAttributesRequirement`]
|
|
459
476
|
|
|
460
477
|
|Element/Attribute Removal
|
|
461
|
-
|
|
478
|
+
|link:docs/remediation.adoc#no-external-css-remediation[`NoExternalCssRemediation`]
|
|
462
479
|
|Removes external CSS references including @import and external stylesheets
|
|
463
|
-
|
|
480
|
+
|link:docs/requirements.adoc#no-external-css-requirement[`NoExternalCssRequirement`]
|
|
464
481
|
|
|
465
482
|
|Addition
|
|
466
|
-
|
|
483
|
+
|link:docs/remediation.adoc#viewbox-remediation[`ViewboxRemediation`]
|
|
467
484
|
|Adds missing viewBox attributes to root SVG elements
|
|
468
|
-
|
|
485
|
+
|link:docs/requirements.adoc#viewbox-required-requirement[`ViewboxRequiredRequirement`]
|
|
469
486
|
|
|
470
487
|
|Style Processing
|
|
471
|
-
|
|
488
|
+
|link:docs/remediation.adoc#style-promotion-remediation[`StylePromotionRemediation`]
|
|
472
489
|
|Promotes CSS style properties to equivalent SVG attributes
|
|
473
|
-
|
|
490
|
+
|link:docs/requirements.adoc#style-promotion-requirement[`StylePromotionRequirement`]
|
|
474
491
|
|
|
475
492
|
|Reference Fixing
|
|
476
|
-
|
|
493
|
+
|link:docs/remediation.adoc#invalid-id-references-remediation[`InvalidIdReferencesRemediation`]
|
|
477
494
|
|Fixes or removes broken ID references and invalid href attributes
|
|
478
|
-
|
|
495
|
+
|link:docs/requirements.adoc#id-reference-requirement[`IdReferenceRequirement`], `InvalidIdReferencesRequirement`
|
|
479
496
|
|===
|
|
480
497
|
|
|
481
498
|
|
|
@@ -1008,9 +1025,9 @@ document = SvgConform::Document.new(svg_content)
|
|
|
1008
1025
|
result = profile.validate(document)
|
|
1009
1026
|
|
|
1010
1027
|
# Apply remediations if needed
|
|
1011
|
-
if !result.valid? && profile.
|
|
1012
|
-
|
|
1013
|
-
|
|
1028
|
+
if !result.valid? && profile.remediation_count > 0
|
|
1029
|
+
changes = profile.apply_remediations(document)
|
|
1030
|
+
puts "Applied #{changes.length} remediations"
|
|
1014
1031
|
end
|
|
1015
1032
|
----
|
|
1016
1033
|
|
|
@@ -150,12 +150,12 @@ requirements:
|
|
|
150
150
|
type: "IdReferenceRequirement"
|
|
151
151
|
description: "Validates ID references point to existing elements"
|
|
152
152
|
|
|
153
|
-
# Forbidden content - no multimedia,
|
|
153
|
+
# Forbidden content - no multimedia, scripting, etc.
|
|
154
154
|
- id: "forbidden_content"
|
|
155
155
|
type: "ForbiddenContentRequirement"
|
|
156
|
-
description: "Prohibits multimedia,
|
|
157
|
-
forbidden_elements: ["script", "audio", "video", "
|
|
158
|
-
forbidden_attributes: ["onload", "onclick", "
|
|
156
|
+
description: "Prohibits multimedia, scripting content"
|
|
157
|
+
forbidden_elements: ["script", "audio", "video", "set"]
|
|
158
|
+
forbidden_attributes: ["onload", "onclick", "onkeydown", "onkeyup", "onkeypress"]
|
|
159
159
|
|
|
160
160
|
# NEW: No external CSS - reject without remediation
|
|
161
161
|
- id: "no_external_css"
|