html-validate 6.1.2 → 6.1.3
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.
- package/CHANGELOG.md +7 -0
- package/dist/cjs/core.d.ts +5 -4
- package/dist/cjs/core.js +32 -11
- package/dist/cjs/core.js.map +1 -1
- package/dist/es/core.d.ts +5 -4
- package/dist/es/core.js +32 -11
- package/dist/es/core.js.map +1 -1
- package/elements/html5.json +0 -1
- package/package.json +8 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# html-validate changelog
|
|
2
2
|
|
|
3
|
+
### [6.1.3](https://gitlab.com/html-validate/html-validate/compare/v6.1.2...v6.1.3) (2021-11-19)
|
|
4
|
+
|
|
5
|
+
### Bug Fixes
|
|
6
|
+
|
|
7
|
+
- parse `<style>` content as text instead of markup ([0ab61e6](https://gitlab.com/html-validate/html-validate/commit/0ab61e6f9c875f76d0b7725f615808eedf1531fd)), closes [#137](https://gitlab.com/html-validate/html-validate/issues/137)
|
|
8
|
+
- **rules:** handle malformed `style` attribute in `no-inline-style` rule ([7e12d50](https://gitlab.com/html-validate/html-validate/commit/7e12d507785eaf4fbbacf9b6ad53c31d5c6aece0))
|
|
9
|
+
|
|
3
10
|
### [6.1.2](https://gitlab.com/html-validate/html-validate/compare/v6.1.1...v6.1.2) (2021-11-13)
|
|
4
11
|
|
|
5
12
|
### Bug Fixes
|
package/dist/cjs/core.d.ts
CHANGED
|
@@ -51,10 +51,11 @@ declare enum TokenType {
|
|
|
51
51
|
TEXT = 11,
|
|
52
52
|
TEMPLATING = 12,
|
|
53
53
|
SCRIPT = 13,
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
54
|
+
STYLE = 14,
|
|
55
|
+
COMMENT = 15,
|
|
56
|
+
CONDITIONAL = 16,
|
|
57
|
+
DIRECTIVE = 17,
|
|
58
|
+
EOF = 18
|
|
58
59
|
}
|
|
59
60
|
interface Token {
|
|
60
61
|
type: TokenType;
|
package/dist/cjs/core.js
CHANGED
|
@@ -1242,12 +1242,14 @@ var State;
|
|
|
1242
1242
|
State[State["ATTR"] = 5] = "ATTR";
|
|
1243
1243
|
State[State["CDATA"] = 6] = "CDATA";
|
|
1244
1244
|
State[State["SCRIPT"] = 7] = "SCRIPT";
|
|
1245
|
+
State[State["STYLE"] = 8] = "STYLE";
|
|
1245
1246
|
})(State || (State = {}));
|
|
1246
1247
|
|
|
1247
1248
|
var ContentModel;
|
|
1248
1249
|
(function (ContentModel) {
|
|
1249
1250
|
ContentModel[ContentModel["TEXT"] = 1] = "TEXT";
|
|
1250
1251
|
ContentModel[ContentModel["SCRIPT"] = 2] = "SCRIPT";
|
|
1252
|
+
ContentModel[ContentModel["STYLE"] = 3] = "STYLE";
|
|
1251
1253
|
})(ContentModel || (ContentModel = {}));
|
|
1252
1254
|
class Context {
|
|
1253
1255
|
constructor(source) {
|
|
@@ -2927,7 +2929,7 @@ var TRANSFORMER_API;
|
|
|
2927
2929
|
/** @public */
|
|
2928
2930
|
const name = "html-validate";
|
|
2929
2931
|
/** @public */
|
|
2930
|
-
const version = "6.1.
|
|
2932
|
+
const version = "6.1.3";
|
|
2931
2933
|
/** @public */
|
|
2932
2934
|
const homepage = "https://html-validate.org";
|
|
2933
2935
|
/** @public */
|
|
@@ -3613,10 +3615,11 @@ exports.TokenType = void 0;
|
|
|
3613
3615
|
TokenType[TokenType["TEXT"] = 11] = "TEXT";
|
|
3614
3616
|
TokenType[TokenType["TEMPLATING"] = 12] = "TEMPLATING";
|
|
3615
3617
|
TokenType[TokenType["SCRIPT"] = 13] = "SCRIPT";
|
|
3616
|
-
TokenType[TokenType["
|
|
3617
|
-
TokenType[TokenType["
|
|
3618
|
-
TokenType[TokenType["
|
|
3619
|
-
TokenType[TokenType["
|
|
3618
|
+
TokenType[TokenType["STYLE"] = 14] = "STYLE";
|
|
3619
|
+
TokenType[TokenType["COMMENT"] = 15] = "COMMENT";
|
|
3620
|
+
TokenType[TokenType["CONDITIONAL"] = 16] = "CONDITIONAL";
|
|
3621
|
+
TokenType[TokenType["DIRECTIVE"] = 17] = "DIRECTIVE";
|
|
3622
|
+
TokenType[TokenType["EOF"] = 18] = "EOF";
|
|
3620
3623
|
})(exports.TokenType || (exports.TokenType = {}));
|
|
3621
3624
|
|
|
3622
3625
|
/* eslint-disable no-useless-escape */
|
|
@@ -3639,6 +3642,8 @@ const MATCH_CDATA_BEGIN = /^<!\[CDATA\[/;
|
|
|
3639
3642
|
const MATCH_CDATA_END = /^[^]*?]]>/;
|
|
3640
3643
|
const MATCH_SCRIPT_DATA = /^[^]*?(?=<\/script)/;
|
|
3641
3644
|
const MATCH_SCRIPT_END = /^<(\/)(script)/;
|
|
3645
|
+
const MATCH_STYLE_DATA = /^[^]*?(?=<\/style)/;
|
|
3646
|
+
const MATCH_STYLE_END = /^<(\/)(style)/;
|
|
3642
3647
|
const MATCH_DIRECTIVE = /^<!--\s*\[html-validate-(.*?)]\s*-->/;
|
|
3643
3648
|
const MATCH_COMMENT = /^<!--([^]*?)-->/;
|
|
3644
3649
|
const MATCH_CONDITIONAL = /^<!\[([^\]]*?)\]>/;
|
|
@@ -3678,6 +3683,9 @@ class Lexer {
|
|
|
3678
3683
|
case State.SCRIPT:
|
|
3679
3684
|
yield* this.tokenizeScript(context);
|
|
3680
3685
|
break;
|
|
3686
|
+
case State.STYLE:
|
|
3687
|
+
yield* this.tokenizeStyle(context);
|
|
3688
|
+
break;
|
|
3681
3689
|
/* istanbul ignore next: sanity check: should not happen unless adding new states */
|
|
3682
3690
|
default:
|
|
3683
3691
|
this.unhandled(context);
|
|
@@ -3746,11 +3754,14 @@ class Lexer {
|
|
|
3746
3754
|
* Called when entering a new state.
|
|
3747
3755
|
*/
|
|
3748
3756
|
enter(context, state, data) {
|
|
3749
|
-
/* script tags require a different content model */
|
|
3757
|
+
/* script/style tags require a different content model */
|
|
3750
3758
|
if (state === State.TAG && data && data[0][0] === "<") {
|
|
3751
3759
|
if (data[0] === "<script") {
|
|
3752
3760
|
context.contentModel = ContentModel.SCRIPT;
|
|
3753
3761
|
}
|
|
3762
|
+
else if (data[0] === "<style") {
|
|
3763
|
+
context.contentModel = ContentModel.STYLE;
|
|
3764
|
+
}
|
|
3754
3765
|
else {
|
|
3755
3766
|
context.contentModel = ContentModel.TEXT;
|
|
3756
3767
|
}
|
|
@@ -3776,6 +3787,7 @@ class Lexer {
|
|
|
3776
3787
|
], "expected doctype name");
|
|
3777
3788
|
}
|
|
3778
3789
|
*tokenizeTag(context) {
|
|
3790
|
+
/* eslint-disable-next-line consistent-return -- exhaustive switch handled by typescript */
|
|
3779
3791
|
function nextState(token) {
|
|
3780
3792
|
switch (context.contentModel) {
|
|
3781
3793
|
case ContentModel.TEXT:
|
|
@@ -3787,11 +3799,14 @@ class Lexer {
|
|
|
3787
3799
|
else {
|
|
3788
3800
|
return State.TEXT; /* <script/> (not legal but handle it anyway so the lexer doesn't choke on it) */
|
|
3789
3801
|
}
|
|
3802
|
+
case ContentModel.STYLE:
|
|
3803
|
+
if (token && token.data[0][0] !== "/") {
|
|
3804
|
+
return State.STYLE;
|
|
3805
|
+
}
|
|
3806
|
+
else {
|
|
3807
|
+
return State.TEXT; /* <style/> */
|
|
3808
|
+
}
|
|
3790
3809
|
}
|
|
3791
|
-
/* istanbul ignore next: not covered by a test as there is currently no
|
|
3792
|
-
* way to trigger this unless new content models are added but this will
|
|
3793
|
-
* add a saner default if anyone ever does */
|
|
3794
|
-
return context.contentModel !== ContentModel.SCRIPT ? State.TEXT : State.SCRIPT;
|
|
3795
3810
|
}
|
|
3796
3811
|
yield* this.match(context, [
|
|
3797
3812
|
[MATCH_TAG_CLOSE, nextState, exports.TokenType.TAG_CLOSE],
|
|
@@ -3829,6 +3844,12 @@ class Lexer {
|
|
|
3829
3844
|
[MATCH_SCRIPT_DATA, State.SCRIPT, exports.TokenType.SCRIPT],
|
|
3830
3845
|
], "expected </script>");
|
|
3831
3846
|
}
|
|
3847
|
+
*tokenizeStyle(context) {
|
|
3848
|
+
yield* this.match(context, [
|
|
3849
|
+
[MATCH_STYLE_END, State.TAG, exports.TokenType.TAG_OPEN],
|
|
3850
|
+
[MATCH_STYLE_DATA, State.STYLE, exports.TokenType.STYLE],
|
|
3851
|
+
], "expected </style>");
|
|
3852
|
+
}
|
|
3832
3853
|
}
|
|
3833
3854
|
|
|
3834
3855
|
const whitespace = /(\s+)/;
|
|
@@ -6079,7 +6100,7 @@ function getCSSDeclarations(value) {
|
|
|
6079
6100
|
.filter(Boolean)
|
|
6080
6101
|
.map((it) => {
|
|
6081
6102
|
const [property, value] = it.split(":", 2);
|
|
6082
|
-
return { property: property.trim(), value: value.trim() };
|
|
6103
|
+
return { property: property.trim(), value: value ? value.trim() : undefined };
|
|
6083
6104
|
});
|
|
6084
6105
|
}
|
|
6085
6106
|
class NoInlineStyle extends Rule {
|