Re:I created an ephemeral group chat app for strangers
by freetonik on Thursday December 28, 2023 @05:10AM
(#38791937)
You can try escaping HTML submitted from the form. Or even simply detecting the presence of any HTML tag and rejecting such submissiobs with a friendly error message.
[ Parent
| on HN ]
Re:I created an ephemeral group chat app for strangers
by tejitopia on Thursday December 28, 2023 @05:20AM
(#38791988)
ah yes! i will do this in the next version. someone recomended leaving some of the xss elements like the image and video function with the old school chat vibes but I'm not sure what to do lmaooo
Re:I created an ephemeral group chat app for strangers
by KETHERCORTEX on Thursday December 28, 2023 @05:48AM
(#38792124)
Old school chats and forums dealt with that with special limited markup language for formatting and embedding images or other special elements like youtube videos. Everything outside the limited markup options was treated as text with the replacement of < and > to HTML entities < and > meant to display HTML special characters in text. It was called BBcode, if I recall correctly. It looked something like that:
[b]bold[/b] [i]italic[/i] [img]example.com/image.jpg[/img] [youtube]youtube.com/watch?v=someVideo[/youtube]
Re:I created an ephemeral group chat app for strangers
by MzHN on Thursday December 28, 2023 @06:14AM
(#38792273)
I like to use a small utility function like this and pass user input through it.
function asTextContent(input) {
const tempElement = document.createElement('span');
tempElement.textContent = input;
return tempElement.innerHTML;
}
It will let the browser handle the escaping.