4 ms·
I'm confused as to why you need a "safe" version if you're the one generating and injecting the HTML.
by intrasight 1y ago
I'm confused as to why you need a "safe" version if you're the one generating and injecting the HTML.
- evbogue 1y agoWhy should a web page only have a single person generating and injecting HTML into it?
- intrasight 1y agoA single company. Why would I let another company inject HTML into my page?
- afavour 1y agoThere's this newfangled concept called social media where you let other people post content that exists on your web site. You're rarely allowed to post HTML because of the associated issues with sanitizing it. setHTML could help with that.
- president_zippy 1y agoI just had a flashback to the heyday of MySpace. Now that I think about it though, Neocities has the "social networking" of being able to discover other people's pages and give each other likes and comments. Hmmm...
- mpeg 1y agoOr CMS content, or even anything that comes from the user outside of social media content and could cause a reflected XSS for example, a search query, or a redirect url, or a million other things
- intrasight 1y agoThe analogy doesn't hold markup ;) Whether I generate a whole page or generate a partial page and then add HTML to it is equivalent from a safety perspective.
- matmo 1y agoIsn't this kinda like asking "why does my gun need a safety if I'm the only one consciously pulling the trigger"?
- theendisney 1y agoIt was kind of strange to have bbcode and wiki markup specifically to avoid allowing users to use html.
- masklinn 1y agoGruber’s original markdown tool passes HTML straight through, it was designed to make writing long-form content easier. Markdown implementations can do any of that, only allowing a whitelist of HTML elements (GFM), or not allowing HTML at all.
- halapro 1y agoIf you generate it from completely static and known values, have at it. If you include user-provided data, then you should sanitize it for HTML.
- jeroenhd 1y agoAs it turns out, verifying that HTML is safe to render without neutering HTML down to a whitelist of elements is actually quite difficult. That's not great when you're rendering user-generated content. Solutions in the form of pre-existing HTML sanitisation libraries have existed for years but countless websites still manage to get XSS'd every year because not everyone capable of writing code is capable of writing secure code.
- masklinn 1y ago1. Because you commonly are not. 2. Because it’s really easy to fuck up and leak attacker controlled content in markup, especially when the environment provides tons of tools to do things wrong and none to do things right. IME even when the environment provides tons of tools to do things right it’s an uphill battle (universe, idiots, yadda yadda).
- zarzavat 1y agoMarkdown parsers output unsafe HTML.
- idreyn 1y agoIt is to render untrusted (user-generated) HTML without letting them slip in markup like script tags that could harm other users.
- bawolff 1y agoBecause sometimes you generate html based on user input and upwards of 98% of web related security vulnerabilities have been this.