浏览代码

Replace chars to prevent a broken regex (#5944)

Co-authored-by: Dennis Hernández <dennishernandezvargas@gmail.com>
Dustin Utecht 4 年之前
父节点
当前提交
f85dd28010
共有 1 个文件被更改,包括 2 次插入1 次删除
  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