diff --git a/extensions/markdown/preview-src/csp.ts b/extensions/markdown/preview-src/csp.ts index 90e19c90f87..32202952258 100644 --- a/extensions/markdown/preview-src/csp.ts +++ b/extensions/markdown/preview-src/csp.ts @@ -4,11 +4,9 @@ *--------------------------------------------------------------------------------------------*/ import { getSettings } from './settings'; +import { getStrings } from './strings'; import { postCommand } from './messaging'; -const strings = JSON.parse(document.getElementById('vscode-markdown-preview-data').getAttribute('data-strings')); -const settings = getSettings(); - /** * Shows an alert when there is a content security policy violation. */ @@ -28,6 +26,9 @@ export class CspAlerter { } private showCspWarning() { + const strings = getStrings(); + const settings = getSettings(); + if (this.didShow || settings.disableSecurityWarnings) { return; } diff --git a/extensions/markdown/preview-src/strings.ts b/extensions/markdown/preview-src/strings.ts new file mode 100644 index 00000000000..a4de5f0b49b --- /dev/null +++ b/extensions/markdown/preview-src/strings.ts @@ -0,0 +1,8 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +export function getStrings(): { [key: string]: string } { + return JSON.parse(document.getElementById('vscode-markdown-preview-data').getAttribute('data-strings')); +}