Feature: Add the ability to @ mention users.#105
Conversation
|
1700 line MR 😭😭😭 Can you explain what is going on here, what is this tiptap library? Also rendering HTML from the user can be very dangerous due to all kinds of injection attacks, are you sure its safe? There are places in the code where you escape HTML manually, im not sure what is going on there but this does not feel like something that should be done by hand (bottom of content.ts). |
|
@Martin092 nice catch by the way, yeah this is a no-go, implementing (open-source) HTML sanitizer is a recipe for disaster (like making our own cryptographic algorithm) |
|
Yeah, sorry @Martin092, I know this first push was a bit of a monolith, but I wasn't 100% sure if Tiptap would be worth it in the end and I really wanted something that could render on screen before I decided for certain that I would keep it. Basically, Tiptap is a modular, headless text editor. It helps with allowing mentions to exist within the text areas for now, but in the future, it could be used to support italics, bulleted lists, code blocks, etc. The reason I wasn't sure if I wanted to keep it was that it felt a bit like over-engineering to wire this in if we were to only use it for mentions. However, upon looking into how to properly support mentions, it became clear that doing so with a bespoke implementation is quite a headache in its own right. So, between the pain of implementing my own mentioning system and integrating Tiptap, I chose the second because that development time at least gives us the option to easily integrate some of those extra features in the future if we choose to do so. The core of wiring into our app basically boils down to three main pieces:
On the HTML part: The escapeHTML related stuff is not actually unsafe, I believe. The only reason it is there is that the original intention was to have backwards compatibility with the plain text comments we have in the database. What it does is make sure that if we have something like "5 < 10" in a comment, we don't interpret the < as HTML, but instead make sure it is just the actual < character. It is therefore not meant to actually sanitize HTML, but to escape it. This point is a bit moot though, because as we discussed with Tom in the meeting, we don't actually need backwards compatibility. I was planning to remove this in favor of simplifying the code, rather than keeping full backwards compatible comment rendering when the comments currently in our database aren't needed anyway. You are right to be worried about the fact that we need to render the comments via |
TipTap JSON object
RichTextRenderer and add html sanitization before rendering
No description provided.