конвертируем Bemhtml в Bh
block input { tag: 'span' mix: { block: 'clearfix' } default: { this._attrs = this.ctx.attrs; delete this.ctx.attrs; applyNext(); } content: { return { elem: 'control', tag: 'input', attrs: this._attrs } } }
module.exports = function (bh) { bh.match('input', function (ctx, json) { ctx.tParam('_attrs', json.attrs); delete json.attrs; ctx.tag('span', true); ctx.mix([{ 'block': 'clearfix' }] .concat(ctx.mix())); ctx.content({ 'elem': 'control', 'tag': 'input', 'attrs': ctx.tParam('_attrs') }, true); }); };
[ { "block": "input", "attrs": { "value": "<script>alert('xss');</script>", "name": "text", "tabindex": 1, "type": "search", "autocomplete": "off", "maxlength": 400 } } ]
<span class="input clearfix"> <input class="input__control" value="<script>alert('xss');</script>" name="text" tabindex="1" type="search" autocomplete="off" maxlength="400"/> </span>
tokenize < input | parse | serialise
tokenize < input | parse | serialise
или ...