Highlighting causes "Invalid regular expression" when text contains brackets or points
See original GitHub issueBootstraptable version(s) affected
1.19.0
Description
If the highlighter is used on columns that contain parentheses ( “[”, “]”, “(” or “)”), then an exception occurs. This seems to happen only with isHTML, because there a replace is done with the TextContent. This TextContent contains the brackets and therefore this is part of the RegEx. The TextContent would have to escape the brackets and perhaps also points before.
In code it’s line 1602:
defValue = value.replace(new RegExp('(>\\s*)(${textContent})(\\s*)', 'gm'), '$1${textReplaced}$3')
Excpetion: bootstrap-table.js:5609 Uncaught SyntaxError: Invalid regular expression: /(>\s*)(Executed DbCommand (0ms) [Parameters=[@__id_0=‘2’], CommandType=‘Text’, CommandTimeout=‘30’] SELECT TOP(1) [k].[KundenId], [k].[ContactPersonName], [k].[ContactPersonPhone], [k].[CurrentUserCount], […)(\s*)/: Unterminated character class at new RegExp (<anonymous>) at bootstrap-table.js:5609 at Array.forEach (<anonymous>) at _class.initRow (bootstrap-table.js:5504) at _class.initBody (bootstrap-table.js:5693) at _class.load (bootstrap-table.js:6498) at Object.success (bootstrap-table.js:5968) at y (bundle.min.js?v=hNhfPDGCO8NKbO5bs-qED6Kq9wSl5PxyUBi_3SCDFgs:2) at Object.fireWith [as resolveWith] (bundle.min.js?v=hNhfPDGCO8NKbO5bs-qED6Kq9wSl5PxyUBi_3SCDFgs:2) at b (bundle.min.js?v=hNhfPDGCO8NKbO5bs-qED6Kq9wSl5PxyUBi_3SCDFgs:2) (anonym) @ bootstrap-table.js:5609 initRow @ bootstrap-table.js:5504 initBody @ bootstrap-table.js:5693 load @ bootstrap-table.js:6498 success @ bootstrap-table.js:5968
Example(s)
No response
Possible Solutions
No response
Additional Context
No response
Issue Analytics
- State:
- Created 2 years ago
- Comments:10
Top GitHub Comments
I guess there are some more chars which should be escaped. The following should do the job.
Example: https://regex101.com/r/b1d1p4/1
I will give it a try today.