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

w2grid markSearch() not properly escaping values when highlighting search results #2490

Open
ryanjbudhu opened this issue Feb 8, 2024 · 5 comments

Comments

@ryanjbudhu
Copy link

Currently in our grid we have emails contained in < and > (e.g. Test User <testemail@example.com>). We can properly escape them with our own function so it displays properly in the grid without an issue. However, when you perform a search (e.g. search for "test") it seems like in w2utils.js converts any properly escaped values into HTML anyway, which breaks the display and adds an extra malformed <span> tag with some info in it.

It seems like some regex is used to clear the markers/add markers which could probably be changed to building actual DOM elements to avoid any HTML injection as well. For now we've turned highlighting off but it is a nice UI feature that we'd like to use.

@ryanjbudhu
Copy link
Author

Upon further inspection, it seems like the recordTitles property of w2grid actually affects this. Having that option on for the grid will result in the broken cell value (and in turn broken title as well).

@vitmalina
Copy link
Owner

I need an example. I cannot replicate it. Can you create JS fiddle?

I tried to use &lt; and &gt; and it seems to work. It's unlikely to work with search though

@ryanjbudhu
Copy link
Author

I made a JS Fiddle here: https://jsfiddle.net/7rja0f53/
Just use the search (with advanced on) to search for "doe" and see that it reformats the email column cell texts to look weird.

@ryanjbudhu
Copy link
Author

It also messes up the text displaying in the "title" (on hover):
image

@ryanjbudhu
Copy link
Author

Any update on this, does the JS Fiddle I provided help?

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