From 6db132b1f5395675bbb5f73a1ea3677a837545cf Mon Sep 17 00:00:00 2001 From: wupengFEX Date: Mon, 8 Jan 2018 12:56:05 +0800 Subject: [PATCH 01/24] =?UTF-8?q?feat:=20=E4=BF=AE=E6=94=B9=20link=20?= =?UTF-8?q?=E6=A0=A1=E9=AA=8C=E8=A7=84=E5=88=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rules.json | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/rules.json b/rules.json index aa7d454..314cae3 100644 --- a/rules.json +++ b/rules.json @@ -53,31 +53,25 @@ }, "link": { "mandatory": [{ - "rel": "/^(miphtml)|(canonical)|(standardhtml)$/" + "rel": "/^(canonical)|(standardhtml)$/" }, { "rel": "/^stylesheet$/", - "href": "/^(https:)?\/\/(mipcache.bdstatic.com\/static\/mipmain)|(m.baidu.com\/static\/ala\/sf\/static\/)|((https:)?\/\/mipcache.bdstatic.com\/static\/v\\d\/)|((https:)?\/\/c.mipcdn.com\/static\/v\\d\/)|((https:)?\/\/c.mipcdn.com\/static\/mipmain)/" + "href": "/^(https:)?\/\/((mipcache\\.bdstatic\\.com\/static\/mipmain-v\\d\\.\\d\\.\\d\\.css)|(c\\.mipcdn\\.com\/static\/mipmain-v\\d\\.\\d\\.\\d\\.css)|(mipcache\\.bdstatic\\.com\/static\/v\\d\/mip\\.css)|(c\\.mipcdn\\.com\/static\/v\\d\/mip\\.css))$/" }], - "mandatory_parent": "head", "duplicate": [{ - "rel": "/^(miphtml)|(standardhtml)$/" - }, { - "rel": "/^(miphtml)|(canonical)$/" - }, { - "rel": "/^stylesheet$/", - "href": "/^(https:)?\/\/(mipcache.bdstatic.com\/static\/mipmain)|(m.baidu.com\/static\/ala\/sf\/static\/)|(c.mipcdn.com\/static\/mipmain)/" + "rel": "/^(canonical)|(standardhtml)$/" }], "attrs": { "href": [{ "value": "/^(http(s)?:)?\/\//", "match": { - "rel": "/^(miphtml)|(canonical)|(standardhtml)$/" + "rel": "/^(canonical)|(standardhtml)$/" } }, { "value": "/^(?!\/[^\/])/", "match": { - "rel": "/^(?!(miphtml)|(canonical)|(standardhtml))$/" + "rel": "/^(?!(canonical)|(standardhtml))$/" } }] From 8b31d7d90c5226004bdce2ebdd2459a83c922f14 Mon Sep 17 00:00:00 2001 From: wupengFEX Date: Mon, 8 Jan 2018 15:40:06 +0800 Subject: [PATCH 02/24] =?UTF-8?q?docs:=20=E4=BF=AE=E6=94=B9=E5=A4=A7?= =?UTF-8?q?=E5=B0=8F=E5=86=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rules.json | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/rules.json b/rules.json index 314cae3..d31195f 100644 --- a/rules.json +++ b/rules.json @@ -80,13 +80,12 @@ "script": [ { "mandatory": { - "type": "/^(text\/javascript)?/", - "src": "/^(https:)?\/\/(mipcache.bdstatic.com\/static\/mipmain)|(m.baidu.com\/static\/ala\/sf\/static\/)|((https:)?\/\/mipcache.bdstatic.com\/static\/v\\d\/)|((https:)?\/\/c.mipcdn.com\/static\/v\\d\/)|((https:)?\/\/c.mipcdn.com\/static\/mipmain)/" + "src": "/^(https:)?\/\/((mipcache\\.bdstatic\\.com\/static\/mipmain-v\\d\\.\\d\\.\\d\\.js)|(c\\.mipcdn\\.com\/static\/mipmain-v\\d\\.\\d\\.\\d\\.js)|(mipcache\\.bdstatic\\.com\/static\/v\\d\/mip\\.js)|(c\\.mipcdn\\.com\/static\/v\\d\/mip\\.js))$/" } }, { "match": { - "src": "/^(https:)?\/\/(mipcache.bdstatic.com\/static\/mipmain)|(m.baidu.com\/static\/ala\/sf\/static\/)|((https:)?\/\/mipcache.bdstatic.com\/static\/v\\d\/)|((https:)?\/\/c.mipcdn.com\/static\/v\\d\/)|((https:)?\/\/c.mipcdn.com\/static\/mipmain)/" + "src":"/^(https:)?\/\/((mipcache\\.bdstatic\\.com)|(c\\.mipcdn\\.com))/" }, "attrs": { "type": { @@ -96,7 +95,7 @@ }, { "match_ancestor": "head", "match": { - "src":"/^((https:)?\/\/mipcache.bdstatic.com)|((https:)?\/\/m.baidu.com\/static\/ala\/sf\/static\/)|((https:)?\/\/c.mipcdn.com)/" + "src":"/^(https:)?\/\/((mipcache\\.bdstatic\\.com)|(c\\.mipcdn\\.com))/" }, "attrs": { "async": { @@ -107,7 +106,7 @@ "disallow": true, "match": { "type": "/^(?!application\/(ld\\+)?json)/", - "src":"/^(?!((https:)?\/\/mipcache.bdstatic.com)|((https:)?\/\/m.baidu.com\/static\/ala\/sf\/static\/)|((https:)?\/\/c.mipcdn.com))/" + "src":"/^(?!((https:)?\/\/mipcache\\.bdstatic\\.com)|((https:)?\/\/c\\.mipcdn\\.com))/" } }, { "disallowed_ancestor": "template" @@ -120,9 +119,6 @@ } } }, - - - "img": { "disallow": true }, From 1aba77fb41009b3d6cfc86b56b7424da454636fe Mon Sep 17 00:00:00 2001 From: wupengFEX Date: Mon, 8 Jan 2018 15:49:24 +0800 Subject: [PATCH 03/24] =?UTF-8?q?=E4=BF=AE=E6=94=B9mip-form=E6=AD=A3?= =?UTF-8?q?=E5=88=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rules.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rules.json b/rules.json index d31195f..b0e38e9 100644 --- a/rules.json +++ b/rules.json @@ -272,7 +272,7 @@ "mip-form": { "attrs": { "method": { - "value": "/^(post)|(get)$/i" + "value": "/^((post)|(get))$/i" }, "url": { "mandatory": true, From 806c028f65d3e4f6797793649a8989580d99ba23 Mon Sep 17 00:00:00 2001 From: wupengFEX Date: Mon, 8 Jan 2018 16:18:45 +0800 Subject: [PATCH 04/24] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9utf-8=E5=88=A4?= =?UTF-8?q?=E6=96=AD=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rules.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rules.json b/rules.json index b0e38e9..49ec1cc 100644 --- a/rules.json +++ b/rules.json @@ -26,7 +26,7 @@ }, { "http-equiv": "/Content-Type/i" }, { - "charset": "/^(UTF-8)/i" + "charset": "/^utf-8$/i" }], "attrs": { "content": [{ @@ -41,9 +41,9 @@ }, "mandatory_or": [{ "http-equiv": "/Content-Type/i", - "content": "/charset=(utf)|(UTF)-8/" + "content": "/charset=utf-8/i" }, { - "charset": "/^(utf)|(UTF-8)/" + "charset": "/^utf-8$/i" }], "mandatory": { "name": "/^(viewport)?/", From 098912af450d0fc3d916305412ae0444c9d23066 Mon Sep 17 00:00:00 2001 From: wupengFEX Date: Mon, 8 Jan 2018 19:44:07 +0800 Subject: [PATCH 05/24] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20source=20=E7=88=B6?= =?UTF-8?q?=E5=85=83=E7=B4=A0=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rules.json | 2 +- src/validators/mandatory_tag_ancestor.js | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/rules.json b/rules.json index 49ec1cc..50748ec 100644 --- a/rules.json +++ b/rules.json @@ -202,7 +202,7 @@ } }, "source": { - "mandatory_ancestor": "mip-video", + "mandatory_ancestor": "/picture|mip-video|mip-audio/", "attrs": { "src": { "mandatory": true, diff --git a/src/validators/mandatory_tag_ancestor.js b/src/validators/mandatory_tag_ancestor.js index 710830c..a4953e0 100644 --- a/src/validators/mandatory_tag_ancestor.js +++ b/src/validators/mandatory_tag_ancestor.js @@ -1,10 +1,11 @@ const ERR = require('../error/dfn.json') +const matcher = require('../matcher.js') exports.onNode = function(node, rule, error) { if (!rule.mandatory_ancestor) return for (var cur = node.parentNode; cur && cur.nodeName; cur = cur.parentNode) { - if (rule.mandatory_ancestor === cur.nodeName) { + if (matcher.matchValue(cur.nodeName, rule.mandatory_ancestor)) { return } } From 7ca9468c6c4c4156185ec1439483dacce8c4593d Mon Sep 17 00:00:00 2001 From: wupengFEX Date: Tue, 9 Jan 2018 11:32:02 +0800 Subject: [PATCH 06/24] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20initical-scale=20?= =?UTF-8?q?=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rules.json | 4 +--- src/validators/invalid_property_value_in_attr_value.js | 5 +++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/rules.json b/rules.json index 50748ec..3ff1cf6 100644 --- a/rules.json +++ b/rules.json @@ -35,7 +35,7 @@ }, "properties": { "width": "device-width", - "initial-scale": "1" + "initial-scale": "/^1(\\.0)?$/" } }] }, @@ -164,8 +164,6 @@ "option": { "mandatory_ancestor": "mip-form" }, - - "a": { "attrs": { "href": { diff --git a/src/validators/invalid_property_value_in_attr_value.js b/src/validators/invalid_property_value_in_attr_value.js index 88ec341..022052f 100644 --- a/src/validators/invalid_property_value_in_attr_value.js +++ b/src/validators/invalid_property_value_in_attr_value.js @@ -1,5 +1,6 @@ const _ = require('lodash') const ERR = require('../error/dfn.json') +const matcher = require('../matcher.js') exports.onAttr = function(attr, attrRule, node, nodeRule, error) { if (!attrRule.properties) return @@ -10,8 +11,8 @@ exports.onAttr = function(attr, attrRule, node, nodeRule, error) { name: key, value: obj[key] } - - if (property.value === value) return + + if (matcher.matchValue(property.value, value)) return error(ERR.INVALID_PROPERTY_VALUE_IN_ATTR_VALUE, node.nodeName, attr.name, From 427480024500b4c71161783de3f2ad553388b394 Mon Sep 17 00:00:00 2001 From: wupengFEX Date: Tue, 9 Jan 2018 14:21:40 +0800 Subject: [PATCH 07/24] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=B5=8B=E8=AF=95=20ca?= =?UTF-8?q?ses?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cases/101.html | 4 ++-- cases/102.html | 4 ++-- cases/103.html | 4 ++-- cases/104.html | 4 ++-- cases/105.html | 4 ++-- cases/106.html | 4 ++-- cases/107.html | 4 ++-- cases/108.html | 2 +- cases/109.html | 2 +- cases/110.html | 4 ++-- cases/111.html | 4 ++-- cases/112.html | 2 +- cases/113.html | 4 ++-- cases/114.html | 4 ++-- cases/115.html | 4 ++-- cases/116.html | 4 ++-- cases/117.html | 4 ++-- cases/118.html | 4 ++-- cases/119.html | 4 ++-- cases/120.html | 4 ++-- cases/121.html | 4 ++-- cases/122.html | 4 ++-- cases/123.html | 2 +- cases/124.html | 2 +- cases/125.html | 4 ++-- cases/126.html | 2 +- cases/127.html | 2 +- cases/128.html | 2 +- cases/129.html | 2 +- cases/130.html | 2 +- cases/131.html | 2 +- cases/132.html | 2 +- cases/133.html | 2 +- cases/134.html | 2 +- cases/135.html | 2 +- cases/136.html | 2 +- cases/139.html | 4 ++-- cases/140.html | 4 ++-- cases/141.html | 4 ++-- cases/143.html | 4 ++-- cases/144.html | 4 ++-- cases/144.json | 2 +- cases/145.html | 4 ++-- cases/146.html | 4 ++-- cases/147.html | 4 ++-- cases/148.html | 4 ++-- cases/148.json | 2 +- cases/149.html | 4 ++-- cases/150.html | 4 ++-- cases/151.html | 4 ++-- cases/153.html | 4 ++-- cases/154.html | 4 ++-- cases/155.html | 4 ++-- cases/156.html | 4 ++-- cases/157.html | 4 ++-- cases/158.html | 4 ++-- cases/159.html | 4 ++-- cases/160.html | 2 +- cases/161.html | 2 +- cases/162.html | 4 ++-- cases/163.html | 4 ++-- cases/164.html | 2 +- cases/165.html | 4 ++-- cases/166.html | 4 ++-- cases/167.html | 4 ++-- cases/168.html | 4 ++-- cases/169.html | 4 ++-- cases/170.html | 4 ++-- cases/171.html | 4 ++-- cases/172.html | 4 ++-- cases/173.html | 4 ++-- cases/174.html | 4 ++-- cases/175.html | 2 +- cases/176.html | 2 +- cases/177.html | 4 ++-- cases/178.html | 2 +- cases/179.html | 2 +- cases/180.html | 2 +- cases/181.html | 2 +- cases/182.html | 2 +- cases/183.html | 2 +- cases/184.html | 2 +- cases/185.html | 2 +- cases/186.html | 2 +- cases/187.html | 2 +- cases/188.html | 4 ++-- cases/188.json | 2 +- cases/191.html | 4 ++-- cases/192.html | 4 ++-- cases/193.html | 4 ++-- cases/194.html | 2 +- cases/195.html | 4 ++-- cases/196.html | 4 ++-- cases/197.html | 4 ++-- cases/198.html | 4 ++-- cases/199.html | 4 ++-- cases/200.html | 4 ++-- cases/200.json | 2 +- cases/201.html | 4 ++-- 99 files changed, 162 insertions(+), 162 deletions(-) diff --git a/cases/101.html b/cases/101.html index a37295f..0314f44 100644 --- a/cases/101.html +++ b/cases/101.html @@ -4,7 +4,7 @@ 常买这东西吃竟导致全家短命 - + @@ -103,5 +103,5 @@ - + \ No newline at end of file diff --git a/cases/102.html b/cases/102.html index 98cc6d9..1c19824 100644 --- a/cases/102.html +++ b/cases/102.html @@ -5,7 +5,7 @@ 明星尴尬出丑镜头 一抬手终身遗憾的悲摧瞬间 - + @@ -115,7 +115,7 @@ - + diff --git a/cases/103.html b/cases/103.html index 87ff258..8e4abd9 100644 --- a/cases/103.html +++ b/cases/103.html @@ -4,7 +4,7 @@ 明星尴尬出丑镜头 一抬手终身遗憾的悲摧瞬间 - + @@ -112,7 +112,7 @@ - + \ No newline at end of file diff --git a/cases/104.html b/cases/104.html index 880a341..b00e0df 100644 --- a/cases/104.html +++ b/cases/104.html @@ -5,7 +5,7 @@ 明星尴尬出丑镜头 一抬手终身遗憾的悲摧瞬间 - + @@ -115,7 +115,7 @@ - + diff --git a/cases/105.html b/cases/105.html index f55dc79..bc1ef90 100644 --- a/cases/105.html +++ b/cases/105.html @@ -3,7 +3,7 @@ 下周一到周六河南雨不停 多地有大到暴雨 - + @@ -58,7 +58,7 @@ - + \ No newline at end of file diff --git a/cases/106.html b/cases/106.html index 65f22f7..ff00104 100644 --- a/cases/106.html +++ b/cases/106.html @@ -3,7 +3,7 @@ 下周一到周六河南雨不停 多地有大到暴雨 - + @@ -58,7 +58,7 @@ - + diff --git a/cases/107.html b/cases/107.html index 8a914e7..c4fa80a 100644 --- a/cases/107.html +++ b/cases/107.html @@ -3,7 +3,7 @@ 李小鹏一家庆祝二胎宝宝满月妻子身材恢复神速 - + @@ -87,5 +87,5 @@ - + \ No newline at end of file diff --git a/cases/108.html b/cases/108.html index b31e6dd..8b10df5 100644 --- a/cases/108.html +++ b/cases/108.html @@ -4,7 +4,7 @@ 东京见!大空翼"连接"巴西与日本 安倍变超级玛丽 - +