Explorar o código

Boards.copyTitle - escape string used in regex

John R. Supplee %!s(int64=4) %!d(string=hai) anos
pai
achega
a7bd8d42e8
Modificáronse 1 ficheiros con 1 adicións e 1 borrados
  1. 1 1
      models/boards.js

+ 1 - 1
models/boards.js

@@ -569,7 +569,7 @@ Boards.helpers({
    */
    */
   copyTitle() {
   copyTitle() {
     const m = this.title.match(/^(?<title>.*?)\s*(\[(?<num>\d+)]\s*$|\s*$)/);
     const m = this.title.match(/^(?<title>.*?)\s*(\[(?<num>\d+)]\s*$|\s*$)/);
-    const title = m.groups.title;
+    const title = escapeForRegex(m.groups.title);
     let num = 0;
     let num = 0;
     Boards.find({ title: new RegExp(`^${title}\\s*\\[\\d+]\\s*$`) }).forEach(
     Boards.find({ title: new RegExp(`^${title}\\s*\\[\\d+]\\s*$`) }).forEach(
       board => {
       board => {