Closed Zhen-hao closed 3 years ago
Yes, innerHTML
shoul be error prone because Korolev doesn't manage inserted DOM. However stack trace you show looks anxious. Looks like spring
had been interpreted as JavaScipt for some reason. It can lead to XSS vulnerability.
is there a safer way to embed external HTML?
Convert your HTML to levsha.Node of course. Look at this example https://gist.github.com/fomkin/f3709afdf53dd0a9e06e07eb16b979f2. This code is not production ready, but shows how to do such things.
@fomkin I'm playing with the approach you suggested.
it seems that the result node can get stuck and not receive updates even though the content has changed.
it happens when my state is loaded from a path (hence resolved by the router
).
it works if the state is loaded from an event (hence via the render
).
About the issue:
js""
interpolator doesn't escape special characters. The renderedHtml
string contains them. I think it leads to the error.levsha.Node
can't lead to problems you described. There is no difference in rendering between state from path and state from event.
I'm using this trick to display an embedded HTML generated by user markdown input.
but on the following input (copied from stackoverflow)
Korolev throws an exception