mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 09:36:08 +08:00
ui: use jsesc to pass args
This commit is contained in:
1 parent
97efa45647
commit
e86cd07c37
4 files changed
+9
-7
No files matched your search
@@ -4,6 +4,7 @@ const yaml = require('js-yaml');
|
||||
const serialize = require('serialize-javascript');
|
||||
const nunjucks = require('nunjucks');
|
||||
const { filter } = require('lodash');
|
||||
const jsesc = require('jsesc');
|
||||
const argv = require('cac')().parse();
|
||||
const { findFileSync } = require('@hydrooj/utils/lib/utils');
|
||||
const status = require('@hydrooj/utils/lib/status');
|
||||
@@ -66,6 +67,7 @@ class Nunjucks extends nunjucks.Environment {
|
||||
this.addFilter('ansi', (self) => misc.ansiToHtml(self));
|
||||
this.addFilter('base64_encode', (s) => Buffer.from(s).toString('base64'));
|
||||
this.addFilter('base64_decode', (s) => Buffer.from(s, 'base64').toString());
|
||||
this.addFilter('jsesc', (self) => jsesc(self, { isScriptContext: true }));
|
||||
this.addFilter('bitand', (self, val) => self & val);
|
||||
this.addFilter('replaceBr', (self) => self.toString().replace(/\n/g, '<br>'));
|
||||
this.addFilter('toString', (self) => (typeof self === 'string' ? self : JSON.stringify(self, replacer)));
|
||||
|
||||
Reference in new issue
Block a user