diff --git a/core/src/components/loading/test/loading.spec.ts b/core/src/components/loading/test/loading.spec.ts
index 11fa9658d75..8cc81e61512 100644
--- a/core/src/components/loading/test/loading.spec.ts
+++ b/core/src/components/loading/test/loading.spec.ts
@@ -4,6 +4,18 @@ import { config } from '../../../global/config';
import { Loading } from '../loading';
describe('loading: custom html', () => {
+ let consoleWarnSpy: jest.SpyInstance;
+
+ beforeEach(() => {
+ consoleWarnSpy = jest.spyOn(console, 'warn');
+ // Suppress console.warn output from polluting the test output
+ consoleWarnSpy.mockImplementation(() => {});
+ });
+
+ afterEach(() => {
+ consoleWarnSpy.mockRestore();
+ });
+
it('should not allow for custom html by default', async () => {
const page = await newSpecPage({
components: [Loading],
@@ -15,6 +27,17 @@ describe('loading: custom html', () => {
expect(content.querySelector('button.custom-html')).toBe(null);
});
+ it('should discard a message carrying an onload handler', async () => {
+ config.reset({ innerHTMLTemplatesEnabled: true });
+ const page = await newSpecPage({
+ components: [Loading],
+ html: ``,
+ });
+
+ const content = page.body.querySelector('.loading-content')!;
+ expect(content.innerHTML).toEqual('');
+ });
+
it('should allow for custom html', async () => {
config.reset({ innerHTMLTemplatesEnabled: true });
const page = await newSpecPage({
diff --git a/core/src/utils/sanitization/index.ts b/core/src/utils/sanitization/index.ts
index bb851fea7e0..ea590fdcdd9 100644
--- a/core/src/utils/sanitization/index.ts
+++ b/core/src/utils/sanitization/index.ts
@@ -1,4 +1,4 @@
-import { printIonError } from '@utils/logging';
+import { printIonError, printIonWarning } from '@utils/logging';
/**
* Sanitize an untrusted HTML string.
@@ -19,8 +19,8 @@ import { printIonError } from '@utils/logging';
* @param untrustedString - The HTML string to sanitize. Pass an
* `IonicSafeString` to bypass sanitization, or `undefined` to short-circuit.
* @returns The sanitized HTML string, or `undefined` if the input was
- * `undefined`. Returns `''` if sanitization fails or the input contains
- * an inline `onload=` handler.
+ * `undefined`. Returns `''` if sanitization fails or the input appears to
+ * carry an inline `onload` handler.
*/
export const sanitizeDOMString = (untrustedString: IonicSafeString | string | undefined): string | undefined => {
try {
@@ -32,12 +32,18 @@ export const sanitizeDOMString = (untrustedString: IonicSafeString | string | un
}
/**
- * onload is fired when appending to a document
- * fragment in Chrome. If a string
- * contains onload then we should not
- * attempt to add this to the fragment.
+ * In Blink a non-outermost `