Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nick highlight should match word boundaries #819

Open
calzoneman opened this issue Jul 9, 2019 · 5 comments
Open

Nick highlight should match word boundaries #819

calzoneman opened this issue Jul 9, 2019 · 5 comments

Comments

@calzoneman
Copy link
Owner

Been reported a few times, should be fixed at some point. The current highlight check is indexOf() but it should do a regular expression match of word boundaries to avoid triggering on usernames that are substrings of other words.

@twilight-sparkle-irl
Copy link

It also, for the record, highlights when the username is in HTML and not the actual text of the message.

@calzoneman
Copy link
Owner Author

Yeah, emotes trigger it as well -- maybe walking the DOM tree (after the message is parsed) for TextNodes might address that.

@twilight-sparkle-irl
Copy link

Why not just use innerText/textContent?

@calzoneman
Copy link
Owner Author

Inspecting innerText on the root of the message's DOM may have subtle edge cases around word boundaries, e.g. <span>foo</span><span>bar</span> getting merged into foobar when in the source HTML it was semantically 2 separate fragments of text.

I also realized if I strip highlights from HTML attributes after emote conversion it might break some legitimate use cases -- for example, people who assign emotes to people's usernames to display an icon instead of text (but still intend to highlight).

@twilight-sparkle-irl
Copy link

twilight-sparkle-irl commented Dec 7, 2019

Perhaps sending the initial unfiltered chat message and doing mentions based on that would work? Most of the cases where people want to mention someone would involve them typing it in themselves, so I figure that'd be a better solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants