-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Typeahead highlight displays <strong> tag when empty spaces added at the end of query and does not escape html tags #4350
Comments
Ngx-bootstrap doesn't include this particular case. If you get an object with html tag, you should convert it by yourself. If a returned object doesn't consist string with html tag, everything will work fine |
Fair enough, thanks for the update.
The first example in my bug report (typing |
What is the progress? |
We have an angular web application which uses typeahead. One of the dropdown menus is a list of antenna-radome types that have fixed length of 20 characters and consist of two parts: antenna type and radome type. As radome type is always the last 4 chars, there are multiple spaces between antenna and radome types, which causes the same problem as pouellet described above.
We currently use other third-party typeahead package which is not ideal. We are keen to use ngx-bootstrap/typeahead once this issue was fixed. |
any update on this ?? |
Here I have tried the fix. |
@valorkin there is a PR raised to fix this issue by @UdayAppam. Any plans to take this up? |
@valorkin my company would also like to see this fix used. Can offer a reward. |
I can fix that issue, how much reward I get |
@ReaPer343 Sorry, just seen this message. I already fixed it and have since changed companies. Thanks for the offer. |
Bug description
This only happens when retrieving data asynchronously. We are using typeahead to trigger a quick search and display the three most relevant search results. We trim spaces around our search query, so a search with
'Ala '
(two trailing spaces) would returnAlabama
andAlaska
. When this happens, the typeahead highlighting function mixes up the highlighting indexes and end up displaying stuff liketrong>Alabama
.Similarly, if the data returned contains html, the html is not escaped. So if the backends return
<script>Bermuda</script>
and<i>Bern</i>
when typingBe
, then we end up with something like this:Luckily, Angular detects the
<script>
tag as malicious and drops it, but it still result in messed up display and a few warnings in the console.As a workaround, we are now wrapping the highlighting function with the following code:
Plunker/StackBlitz that reproduces the issue
Extracted from the async demo, with a small change in the Regex to allow
Ala
to returnAlabama
. Also shows the issues with the html escape by typingBe
. The second dropdown uses the workaround mentioned above to fix the issues.https://stackblitz.com/edit/ngx-bootstrap-typeahead-highlight-bug
Versions of ngx-bootstrap, Angular, and Bootstrap
ngx-bootstrap: 2.0.5
Angular: 4.x, 5.x
The text was updated successfully, but these errors were encountered: