@syncfusion/ej2-base 31.1.22 → 31.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6270,6 +6270,19 @@ class DateParser {
6270
6270
  }
6271
6271
  return null;
6272
6272
  }
6273
+ /**
6274
+ * Escapes all regex metacharacters in a string, preserving the {0} placeholder.
6275
+ *
6276
+ * @param {string} str ? - The input string to escape.
6277
+ * @returns {string} ? - The escaped string with {0} preserved.
6278
+ */
6279
+ static escapeRegex(str) {
6280
+ const tempPlaceholder = '__TEMP__';
6281
+ const tempStr = str.replace('{0}', tempPlaceholder);
6282
+ const metaChars = /[.*+?^${}()|[\]\\]/g;
6283
+ const escapedStr = tempStr.replace(metaChars, '\\$&');
6284
+ return escapedStr.replace(tempPlaceholder, '{0}');
6285
+ }
6273
6286
  /**
6274
6287
  * Returns parsed time zone RegExp for provided hour format and time zone
6275
6288
  *
@@ -6279,7 +6292,7 @@ class DateParser {
6279
6292
  * @returns {string} ?
6280
6293
  */
6281
6294
  static parseTimeZoneRegx(hourFormat, tZone, nRegex) {
6282
- const pattern = tZone.gmtFormat;
6295
+ let pattern = tZone.gmtFormat;
6283
6296
  let ret;
6284
6297
  const cRegex = '(' + nRegex + ')' + '(' + nRegex + ')';
6285
6298
  ret = hourFormat.replace('+', '\\+');
@@ -6289,10 +6302,12 @@ class DateParser {
6289
6302
  else {
6290
6303
  ret = ret.replace(/H|m/g, '(' + cRegex + '?)');
6291
6304
  }
6305
+ pattern = this.escapeRegex(pattern);
6292
6306
  const splitStr = (ret.split(';').map((str) => {
6293
6307
  return pattern.replace('{0}', str);
6294
6308
  }));
6295
- ret = splitStr.join('|') + '|' + tZone.gmtZeroFormat;
6309
+ const gmtZeroFormat = this.escapeRegex(tZone.gmtZeroFormat);
6310
+ ret = splitStr.join('|') + '|' + gmtZeroFormat;
6296
6311
  return ret;
6297
6312
  }
6298
6313
  /**