diff --git a/core/package.json b/core/package.json index 68bb49129e..5529541410 100644 --- a/core/package.json +++ b/core/package.json @@ -34,7 +34,7 @@ "tslib": "^1.10.0" }, "devDependencies": { - "@stencil/core": "1.2.5", + "@stencil/core": "1.3.1", "@stencil/sass": "1.0.1", "@types/jest": "24.0.17", "@types/node": "12.7.1", diff --git a/core/src/components/router/router.tsx b/core/src/components/router/router.tsx index 85e72742ee..7a59d038f6 100644 --- a/core/src/components/router/router.tsx +++ b/core/src/components/router/router.tsx @@ -104,7 +104,7 @@ export class Router implements ComponentInterface { * Go back to previous page in the window.history. */ @Method() - back() { + back(): Promise { window.history.back(); return Promise.resolve(this.waitPromise); } diff --git a/core/src/utils/sanitization/index.ts b/core/src/utils/sanitization/index.ts index 1486a682d9..c2bdbd2fb8 100644 --- a/core/src/utils/sanitization/index.ts +++ b/core/src/utils/sanitization/index.ts @@ -84,7 +84,7 @@ const sanitizeElement = (element: any) => { if (element.nodeType && element.nodeType !== 1) { return; } for (let i = element.attributes.length - 1; i >= 0; i--) { - const attribute = element.attributes[i]; + const attribute = element.attributes.item(i); const attributeName = attribute.name; // remove non-allowed attribs diff --git a/core/src/utils/sanitization/test/e2e.ts b/core/src/utils/sanitization/test/e2e.ts deleted file mode 100644 index 513946f573..0000000000 --- a/core/src/utils/sanitization/test/e2e.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { newE2EPage } from '@stencil/core/testing'; - -test('sanitization:', async done => { - - const page = await newE2EPage({ - url: '/src/utils/sanitization/test?ionic:_testing=true' - }); - - page.on('pageerror', (err: any) => { - if (err.message.includes('sanitizeFailed')) { - done.fail(new Error('Failed to properly sanitize')); - } - }); - - await page.click('#testA'); - await page.click('#testB'); - await page.click('#testC'); - await page.click('#testD'); - await page.click('#testE'); - await page.click('#testF'); - await page.click('#testG'); - await page.click('#testH'); - - done(); - -}); diff --git a/core/src/utils/sanitization/test/index.html b/core/src/utils/sanitization/test/index.html deleted file mode 100644 index f3874e37dc..0000000000 --- a/core/src/utils/sanitization/test/index.html +++ /dev/null @@ -1,114 +0,0 @@ - - - - - Sanitization - - - - - - - - - - - - - - - - - Sanitization - - - - -
Results will appear here
- - Test A - Test B - Test C - Test D - Test E - Test F - Test G - Test H -
- -
- - - - - diff --git a/core/src/utils/sanitization/test/sanitization.spec.ts b/core/src/utils/sanitization/test/sanitization.spec.ts new file mode 100644 index 0000000000..83ee9a0586 --- /dev/null +++ b/core/src/utils/sanitization/test/sanitization.spec.ts @@ -0,0 +1,44 @@ +import { sanitizeDOMString } from ".."; + +describe('sanitizeDOMString', () => { + + it('filter onerror', () => { + expect(sanitizeDOMString('')) + .toEqual(''); + }); + + it('filter onclick', () => { + expect(sanitizeDOMString('')) + .toEqual(''); + }); + + it('filter href JS', () => { + expect(sanitizeDOMString('harmless link')) + .toEqual('harmless link'); + }); + + it('filter href JS + class attribute', () => { + expect(sanitizeDOMString('harmless link')) + .toEqual('harmless link'); + }); + + it('filter ')) + .toEqual(''); + }); + + it('filter href + javascript ', () => { + expect(sanitizeDOMString('
')) + .toEqual('
'); + }); + + it('filter ', () => { + expect(sanitizeDOMString('')) + .toEqual(''); + }); + + it('sanitizeDOMString', () => { + expect(sanitizeDOMString('Hello!Click me')) + .toEqual('Hello!Click me'); + }); +}); \ No newline at end of file