Only using known handlers with handlebars (#27061) (#27313)

This commit is contained in:
Brandon Kobel 2019-01-18 06:43:28 -08:00 committed by GitHub
parent 16b6eafcc9
commit bdf0ef6a67
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 6 additions and 4 deletions

View file

@ -23,7 +23,7 @@ import { i18n } from '@kbn/i18n';
export default function replaceVars(str, args = {}, vars = {}) {
try {
const template = handlebars.compile(str, { strict: true });
const template = handlebars.compile(str, { strict: true, knownHelpersOnly: true });
const string = template(_.assign({}, vars, { args }));

View file

@ -29,7 +29,7 @@ const durationsLookup = durationInputOptions.reduce((acc, row) => {
export default (format = '0,0.[00]', template, getConfig = null) => {
if (!template) template = '{{value}}';
const render = handlebars.compile(template);
const render = handlebars.compile(template, { knownHelpersOnly: true });
const durationFormatTest = /[pnumshdwMY]+,[pnumshdwMY]+,\d+/;
let formatter;
if (durationFormatTest.test(format)) {

View file

@ -54,7 +54,7 @@ async function buildGallery(comparisons) {
const template = Handlebars.compile(await readFileAsync(
path.resolve('./utilities/templates/visual_regression_gallery.handlebars')
, 'utf8'));
, 'utf8'), { knownHelpersOnly: true });
const html = template({
date: moment().format('MMMM Do YYYY, h:mm:ss a'),

View file

@ -30,7 +30,9 @@ export const markdown = () => ({
},
},
fn: (context, args) => {
const compileFunctions = args.expression.map(str => Handlebars.compile(String(str)));
const compileFunctions = args.expression.map(str =>
Handlebars.compile(String(str), { knownHelpersOnly: true })
);
const ctx = {
columns: [],
rows: [],