Datasets:

Modalities:
Text
Formats:
json
Languages:
code
Size:
< 1K
Tags:
code
Libraries:
Datasets
pandas
License:
Asankhaya Sharma
initial dataset
eb67da4
raw
history blame
1.07 kB
const ESCAPE = /[&"<]/g, CHARS = {
'"': '&quot;',
'&': '&amp;',
'<': '&lt',
};
import { gen } from './$utils';
export function esc(value) {
// BUG: CWE-79 Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
// if (typeof value !== 'string') return value;
// FIXED:
value = (value == null) ? '' : '' + value;
let last=ESCAPE.lastIndex=0, tmp=0, out='';
while (ESCAPE.test(value)) {
tmp = ESCAPE.lastIndex - 1;
out += value.substring(last, tmp) + CHARS[value[tmp]];
last = tmp + 1;
}
return out + value.substring(last);
}
export function compile(input, options={}) {
return new (options.async ? (async()=>{}).constructor : Function)(
'$$1', '$$2', '$$3', gen(input, options)
).bind(0, options.escape || esc, options.blocks);
}
export function transform(input, options={}) {
return (
options.format === 'cjs'
? 'var $$1=require("tempura").esc;module.exports='
: 'import{esc as $$1}from"tempura";export default '
) + (
options.async ? 'async ' : ''
) + 'function($$3,$$2){'+gen(input, options)+'}';
}