hack.chat icon indicating copy to clipboard operation
hack.chat copied to clipboard

Added name highlighting

Open Inferno42 opened this issue 9 years ago • 5 comments

Whenever the user's name is mentioned by another person the name is highlighted in red.

Inferno42 avatar Jul 11 '15 05:07 Inferno42

You should maybe escape the name for regex before testing, and also add \b before and after the name so it doesn't mark nicknames mid-word. This could also be combined with the new @nick syntax

WebFreak001 avatar Jul 11 '15 08:07 WebFreak001

The pull now escapes the name and checks for @Name if it has a space before it or a start line plus if it ends (The name) with a space or endline.

Inferno42 avatar Jul 11 '15 21:07 Inferno42

We shouldn't use LaTeX for coloring the names. Putting a <span> around it would be best, but I'd need to audit it for XSS.

On a general note, does anyone know how to match text in textContent and replace it with an HTML element containing the matched text, in a safe way?

AndrewBelt avatar Jul 11 '15 21:07 AndrewBelt

I'd imagine the easiest way to do something like that would be to scrub the change before putting it out, removing anything involving javascript (Including hex).

Inferno42 avatar Jul 12 '15 00:07 Inferno42

you could also use a <code> tag afaik :laughing:

M4GNV5 avatar Jul 12 '15 19:07 M4GNV5