From 5abd2af22463e08b676e06f7202020e1bb636f79 Mon Sep 17 00:00:00 2001 From: joshrmcdaniel <80354972+joshrmcdaniel@users.noreply.github.com> Date: Mon, 27 May 2024 18:43:57 -0500 Subject: [PATCH] check for existing --- privaxy/src/server/web_gui/filters.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/privaxy/src/server/web_gui/filters.rs b/privaxy/src/server/web_gui/filters.rs index 38fec70..2d7fa72 100644 --- a/privaxy/src/server/web_gui/filters.rs +++ b/privaxy/src/server/web_gui/filters.rs @@ -99,6 +99,13 @@ pub async fn add_filter( // Clone the URL to avoid moving the original value let filter_url = add_filter_request.url.clone(); + if configuration.filters.iter().any(|filter| filter.url == add_filter_request.url) { + log::warn!("Filter with URL {} already exists", add_filter_request.url); + return Ok(Response::builder() + .status(http::StatusCode::CONFLICT) + .body("Filter already exists".to_string()) + .unwrap()); + } // Add the new filter to the configuration let mut new_filter = Filter {