mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-16 02:03:07 -07:00
WebUI: Handle regex syntax error for torrent filtering
https://github.com/qbittorrent/qBittorrent/pull/20566#discussion_r1704548226 PR #21173.
This commit is contained in:
parent
04eb40376e
commit
9a8572bd21
1 changed files with 10 additions and 4 deletions
|
@ -1527,13 +1527,19 @@ window.qBittorrent.DynamicTable ??= (() => {
|
||||||
getFilteredAndSortedRows: function() {
|
getFilteredAndSortedRows: function() {
|
||||||
const filteredRows = [];
|
const filteredRows = [];
|
||||||
|
|
||||||
const rows = this.rows.getValues();
|
|
||||||
const useRegex = $("torrentsFilterRegexBox").checked;
|
const useRegex = $("torrentsFilterRegexBox").checked;
|
||||||
const filterText = $("torrentsFilterInput").value.trim().toLowerCase();
|
const filterText = $("torrentsFilterInput").value.trim().toLowerCase();
|
||||||
const filterTerms = (filterText.length > 0)
|
let filterTerms;
|
||||||
? (useRegex ? new RegExp(filterText) : filterText.split(" "))
|
try {
|
||||||
: null;
|
filterTerms = (filterText.length > 0)
|
||||||
|
? (useRegex ? new RegExp(filterText) : filterText.split(" "))
|
||||||
|
: null;
|
||||||
|
}
|
||||||
|
catch (e) { // SyntaxError: Invalid regex pattern
|
||||||
|
return filteredRows;
|
||||||
|
}
|
||||||
|
|
||||||
|
const rows = this.rows.getValues();
|
||||||
for (let i = 0; i < rows.length; ++i) {
|
for (let i = 0; i < rows.length; ++i) {
|
||||||
if (this.applyFilter(rows[i], selected_filter, selected_category, selectedTag, selectedTracker, filterTerms)) {
|
if (this.applyFilter(rows[i], selected_filter, selected_category, selectedTag, selectedTracker, filterTerms)) {
|
||||||
filteredRows.push(rows[i]);
|
filteredRows.push(rows[i]);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue