Skip to content

Commit 9a8572b

Browse files
WebUI: Handle regex syntax error for torrent filtering
qbittorrent#20566 (comment) PR qbittorrent#21173.
1 parent 04eb403 commit 9a8572b

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

src/webui/www/private/scripts/dynamicTable.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1527,13 +1527,19 @@ window.qBittorrent.DynamicTable ??= (() => {
15271527
getFilteredAndSortedRows: function() {
15281528
const filteredRows = [];
15291529

1530-
const rows = this.rows.getValues();
15311530
const useRegex = $("torrentsFilterRegexBox").checked;
15321531
const filterText = $("torrentsFilterInput").value.trim().toLowerCase();
1533-
const filterTerms = (filterText.length > 0)
1534-
? (useRegex ? new RegExp(filterText) : filterText.split(" "))
1535-
: null;
1532+
let filterTerms;
1533+
try {
1534+
filterTerms = (filterText.length > 0)
1535+
? (useRegex ? new RegExp(filterText) : filterText.split(" "))
1536+
: null;
1537+
}
1538+
catch (e) { // SyntaxError: Invalid regex pattern
1539+
return filteredRows;
1540+
}
15361541

1542+
const rows = this.rows.getValues();
15371543
for (let i = 0; i < rows.length; ++i) {
15381544
if (this.applyFilter(rows[i], selected_filter, selected_category, selectedTag, selectedTracker, filterTerms)) {
15391545
filteredRows.push(rows[i]);

0 commit comments

Comments
 (0)