mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-23 16:58:06 -06: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:
@@ -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]);
|
||||
|
||||
Reference in New Issue
Block a user