diff options
author | ache <ache@ache.one> | 2018-05-27 11:07:07 +0200 |
---|---|---|
committer | ache <ache@ache.one> | 2018-05-27 11:07:07 +0200 |
commit | 767f2cb208c2f37376db08cd554456de186a4440 (patch) | |
tree | 23cbab3d293dbadda85c548b51d9e09fe37f691a | |
parent | Test revision with parse5 (diff) |
Add more tests again
-rw-r--r-- | __tests__/index.js | 21 | ||||
-rw-r--r-- | index.js | 2 |
2 files changed, 22 insertions, 1 deletions
diff --git a/__tests__/index.js b/__tests__/index.js index 239e1aa..199b8e4 100644 --- a/__tests__/index.js +++ b/__tests__/index.js @@ -127,3 +127,24 @@ test('extended-global', t => { t.deepEqual(parse(contents), parse(`<p> <em>Wait</em> ! You are <strong ex-attr="true">beautiful</strong> !</p>`)); }); +test('extended-invalid-scope', t => { + const renderExtended = generateExtendParser({scope: 'invalid', extend: {strong: ['exAttr']}}); + const invalidString = `*Wait* ! You are **beautiful**{ exAttr="true" onload="qdss" pss="NOK" } !`; + const {contents} = renderExtended(invalidString); + t.deepEqual(parse(contents), parse(`<p><em>Wait</em> ! You are <strong ex-attr="true">beautiful</strong> !</p>`)); +}); + +test('invalid-scope', t => { + const renderExtended = generateExtendParser({extend: 'exAttr'}); + const invalidString = ` *Wait* ! I **love**{ exAttr="true" onload="qdss" pss="NOK" } you !`; + const {contents} = renderExtended(invalidString); + t.deepEqual(parse(contents), parse(`<p> <em>Wait</em> ! I <strong>love</strong> you !</p>`)); +}); + +test('invalid-extend', t => { + const renderExtended = generateExtendParser({extend: 'exAttr'}); + const invalidString = ` *Wait* ! I **love**{ exAttr="true" onload="qdss" attr="NOK" style="color: red;"} you!`; + const {contents} = renderExtended(invalidString); + t.deepEqual(parse(contents), parse(`<p> <em>Wait</em> ! I <strong style="color: red;">love</strong> you!</p>`)); +}); + @@ -151,6 +151,7 @@ function filterAttributes(prop, config, type) { } break; case 'extended': + default: inScope = p => extendTag && type in extendTag && extendTag[type].indexOf(p) >= 0; inScope = orFunc(inScope, p => '*' in extendTag && extendTag['*'].indexOf(p) >= 0); // Or if it in the specific scope, fallthrough @@ -158,7 +159,6 @@ function filterAttributes(prop, config, type) { inScope = orFunc(inScope, isSpecific); // Or if it in the global scope fallthrough case 'global': - default: inScope = orFunc(inScope, isGlobal); if (allowDangerousDOMEventHandlers) { // If allowed add dangerous attributes to global scope inScope = orFunc(inScope, isDangerous); |