Comments (14)
@f0rmat1k escaping or contentSafe
? It’s opposite things. Escaping any fields means you don’t trust it’s value. But naming the field contentSafe
we assume that its content is safe and it’s value should be output as is.
In BH you can use html field. See test: https://github.com/bem/bh/blob/master/test/test.html.js#L14
from bh.
Feels like it's the same as safe
/unsafe
to mark fields as "need escaping" and "does not need escaping" flags.
I like the way we do it in bem-xjst
: { content: { html: '<script>alert(1);</script>' } }
(same as safe: '<script>alert(1);</script>'
, but I'm agree that opposite will be useful too to not call escaping method directly.
from bh.
@miripiruni I just wanted to say, that now i have to escape handy any content
{
content: escape('content')
}
Global option isn't useful.
Maybe BH should really force escape content
field? And do like react:
{
dangerouslyContent: '<span>content</span>'
}
Anyway for me would be enough some field where i can insert content for escaping.
from bh.
@f0rmat1k I don't understand why option escapeContent:true
doen't do what you want?
from bh.
@Yeti-or because it affects whole project
from bh.
Like that?
bh.match('*', function(ctx, json){
if(json.dangerousContent) {
json.content = bh.escape(json.dangerousContent)
}
})
from bh.
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
from bh.
react escaping affects whole project too
from bh.
@Yeti-or but react has dangerouslySetInnerHtml
from bh.
@f0rmat1k BH has content: { tag: false, html: ... }
that works like dangerouslySetInnerHtml: ...
from bh.
@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.
from bh.
Можно реализовать компрометирующую логику через tParam: выставлять его для всех детей где-то на уровне блока, у которого есть шаблон. То есть компрометировать ветку в BEMJSON, а не узел.
from bh.
Оу, когда я писал про стх, я имел ввиду tParam для поддерева. Я поправлю сниппет
from bh.
Без tParam: https://goo.gl/JvaD4D Кажется, что так даже лучше.
С tParam: https://goo.gl/sAFRbg https://goo.gl/RRU1nW
from bh.
Related Issues (20)
- Readme: describe `bh.toHtml()`
- block vs. block_mod apply bug (order matters!) HOT 6
- Need documentation on new global matcher feature
- jsElem
- jsAttr Defaults: `data-bem` name + `json` scheme HOT 7
- bh.require
- Documentation on escaping utils
- Proposal: ctx.if() HOT 5
- Add more examples for boolean attributes to README
- add tProxy shortcut
- Bug with ctx.js() HOT 6
- BH doesn't extend client 'js' param when it equal true HOT 3
- How to off escaping for .content() HOT 4
- Демо не работает в Firefox
- tParam rewrites value from previous level HOT 2
- How to achieve a bemhtml replace() like behaviour? HOT 7
- Option to drop trailing slashes for short tags
- Remove eval from runtime HOT 2
- Матчинг на элемент по модификатору блока HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bh.