mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-12-28 00:05:25 +00:00
20 lines
535 B
JavaScript
20 lines
535 B
JavaScript
/**
|
|
* Copyright (c) HashiCorp, Inc.
|
|
* SPDX-License-Identifier: BUSL-1.1
|
|
*/
|
|
|
|
import { helper } from '@ember/component/helper';
|
|
import { debug } from '@ember/debug';
|
|
import { htmlSafe } from '@ember/template';
|
|
import { sanitize } from 'dompurify';
|
|
|
|
export default helper(function sanitizedHtml([htmlString]) {
|
|
try {
|
|
return htmlSafe(sanitize(htmlString));
|
|
} catch (e) {
|
|
debug('Error sanitizing string', e);
|
|
// I couldn't get this to actually fail but as a fallback render the value as-is
|
|
return htmlString;
|
|
}
|
|
});
|