-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Description
Describe the problem
We just started a hackaton for the weekend, and decided to use svelte. 2 out of 4 of us had never used it before, so I recommended going through the tutorial.
The first reaction was (translated) "Happy to see that they tell users how to setup for xss attacks at the 4th page of the tutorial"
Followed by "In react they make you write __dangerousInnerHTML
to make it clear that it's a bad idea, but here they are almost selling it as 'look how simple it is'".
They were talking about the @html
tag and its corresponding page in the tutorial.
Describe the proposed solution
the @html
tag is a great feature, but with great powers...
I would take three steps:
- Move the page to the end of the tutorial. Imo it has nothing to do in the introduction.
- Issue an error when
@html
is used, with an option to disable it. - In svelte 4, deprecate
@html
for@dangerousInnerHtml
or something alike.
Alternatives considered
EDIT: Bad alternative
add a sanitize option to @html
blocks
<div>{@html:sanitize content}</div>
That would filter <script>
tags and other "dangerous" elements.
That is probably too complex/dangerous to implement.
Importance
nice to have