Browse Source

Replace chars to prevent a broken regex (#5944)

Co-authored-by: Dennis Hernández <dennishernandezvargas@gmail.com>
Dustin Utecht 4 years ago
parent
commit
f85dd28010
1 changed files with 2 additions and 1 deletions
  1. 2 1
      src/bootstrap-table.js

+ 2 - 1
src/bootstrap-table.js

@@ -1596,9 +1596,10 @@ class BootstrapTable {
 
         if (isHTML) {
           // value can contains a HTML tags
-          const textContent = new DOMParser().parseFromString(value.toString(), 'text/html').documentElement.textContent
+          let textContent = new DOMParser().parseFromString(value.toString(), 'text/html').documentElement.textContent
           const textReplaced = textContent.replace(regExp, marker)
 
+          textContent = textContent.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
           defValue = value.replace(new RegExp(`(>\\s*)(${textContent})(\\s*)`, 'gm'), `$1${textReplaced}$3`)
         } else {
           // but usually not