mirror of
https://github.com/louislam/uptime-kuma.git
synced 2024-12-24 21:24:28 -08:00
fix(monitors search): Make sure regex expressions are escaped.
This can be reverted if the search should be regex friendly, but for the moment, it's not the case. Thanks @homelab-alpha!
This commit is contained in:
parent
d0d03c05d6
commit
c0d7171dbf
|
@ -325,7 +325,11 @@ export default {
|
|||
let searchTextMatch = true;
|
||||
if (this.searchText !== "") {
|
||||
try {
|
||||
const regex = new RegExp(this.searchText, "i"); // "i" for case-insensitive matching
|
||||
// Escape special characters for use in the regular expression
|
||||
const escapeRegExp = (string) => string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
||||
|
||||
const escapedSearchText = escapeRegExp(this.searchText);
|
||||
const regex = new RegExp(escapedSearchText, "i");
|
||||
|
||||
const safeRegexTest = (str) => str && regex.test(str);
|
||||
|
||||
|
|
Loading…
Reference in a new issue