mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-06 21:21:24 -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() {
|
||||
const filteredRows = [];
|
||||
|
||||
const rows = this.rows.getValues();
|
||||
const useRegex = $("torrentsFilterRegexBox").checked;
|
||||
const filterText = $("torrentsFilterInput").value.trim().toLowerCase();
|
||||
const filterTerms = (filterText.length > 0)
|
||||
? (useRegex ? new RegExp(filterText) : filterText.split(" "))
|
||||
: null;
|
||||
let filterTerms;
|
||||
try {
|
||||
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) {
|
||||
if (this.applyFilter(rows[i], selected_filter, selected_category, selectedTag, selectedTracker, filterTerms)) {
|
||||
filteredRows.push(rows[i]);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue