diff --git a/src/webui/www/eslint.config.mjs b/src/webui/www/eslint.config.mjs index 1e84f9d6e..ba6f91a0d 100644 --- a/src/webui/www/eslint.config.mjs +++ b/src/webui/www/eslint.config.mjs @@ -2,9 +2,11 @@ import Globals from 'globals'; import Html from 'eslint-plugin-html'; import Js from '@eslint/js'; import Stylistic from '@stylistic/eslint-plugin'; +import * as RegexpPlugin from 'eslint-plugin-regexp'; export default [ Js.configs.recommended, + RegexpPlugin.configs["flat/recommended"], Stylistic.configs["disable-legacy"], { files: [ @@ -20,6 +22,7 @@ export default [ }, plugins: { Html, + RegexpPlugin, Stylistic }, rules: { diff --git a/src/webui/www/package.json b/src/webui/www/package.json index 7b11828f0..975a90014 100644 --- a/src/webui/www/package.json +++ b/src/webui/www/package.json @@ -14,6 +14,7 @@ "@stylistic/eslint-plugin": "*", "eslint": "*", "eslint-plugin-html": "*", + "eslint-plugin-regexp": "*", "html-validate": "*", "i18next-parser": "*", "js-beautify": "*", diff --git a/src/webui/www/private/scripts/client.js b/src/webui/www/private/scripts/client.js index 5b612aeea..496ca43da 100644 --- a/src/webui/www/private/scripts/client.js +++ b/src/webui/www/private/scripts/client.js @@ -1527,8 +1527,8 @@ window.addEventListener("DOMContentLoaded", function() { return lowercaseStr.startsWith("http:") || lowercaseStr.startsWith("https:") || lowercaseStr.startsWith("magnet:") - || ((str.length === 40) && !(/[^0-9A-Fa-f]/.test(str))) // v1 hex-encoded SHA-1 info-hash - || ((str.length === 32) && !(/[^2-7A-Za-z]/.test(str))); // v1 Base32 encoded SHA-1 info-hash + || ((str.length === 40) && !(/[^0-9A-F]/i.test(str))) // v1 hex-encoded SHA-1 info-hash + || ((str.length === 32) && !(/[^2-7A-Z]/i.test(str))); // v1 Base32 encoded SHA-1 info-hash }); if (urls.length <= 0) diff --git a/src/webui/www/private/scripts/misc.js b/src/webui/www/private/scripts/misc.js index 7ca895ae3..529d19e70 100644 --- a/src/webui/www/private/scripts/misc.js +++ b/src/webui/www/private/scripts/misc.js @@ -143,7 +143,7 @@ window.qBittorrent.Misc = (function() { * JS counterpart of the function in src/misc.cpp */ const parseHtmlLinks = function(text) { - const exp = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#/%?=~_|!:,.;]*[-A-Z0-9+&@#/%=~_|])/ig; + const exp = /(\b(https?|ftp|file):\/\/[-\w+&@#/%?=~|!:,.;]*[-\w+&@#/%=~|])/gi; return text.replace(exp, "$1"); };