-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
What about escaping specific BEMJSON field, e.g. 'contentSafe'? #179
Comments
@f0rmat1k escaping or In BH you can use html field. See test: https://github.com/bem/bh/blob/master/test/test.html.js#L14 |
Feels like it's the same as I like the way we do it in |
@miripiruni I just wanted to say, that now i have to escape handy any content
Global option isn't useful.
Anyway for me would be enough some field where i can insert content for escaping. |
@f0rmat1k I don't understand why option |
@Yeti-or because it affects whole project |
Like that? bh.match('*', function(ctx, json){
if(json.dangerousContent) {
json.content = bh.escape(json.dangerousContent)
}
}) |
Bemjson = {
content: [
'this wont be escaped',
{ unsafe: true, content: [
'But this will be escaped'
] }
]
} And... bh.match('*', function...
if(json.unsafe) {
ctx.unsafe = true
res = ctx.applyBase()
ctx.unsafe = false
return res
}
bh.match('*', function...
if(ctx.unsafe) escape content manually |
react escaping affects whole project too |
@Yeti-or but react has dangerouslySetInnerHtml |
@f0rmat1k BH has |
@zxqfox So i will have to create .bh for every block (usually priv is enought for me). It isn't as simple as specific bemjson field. But thank you for advice. |
Можно реализовать компрометирующую логику через tParam: выставлять его для всех детей где-то на уровне блока, у которого есть шаблон. То есть компрометировать ветку в BEMJSON, а не узел. |
Оу, когда я писал про стх, я имел ввиду tParam для поддерева. Я поправлю сниппет |
Без tParam: https://goo.gl/JvaD4D Кажется, что так даже лучше. |
Something like this:
{ block: 'button', contentSafe: '<script>alert('you shall not pass!')</script> }
The text was updated successfully, but these errors were encountered: