add regex pattern validation via DuckDB

This commit is contained in:
rustmailer
2026-03-05 16:41:30 +08:00
parent 393b7361e8
commit 5f013ea173
2 changed files with 27 additions and 0 deletions
+12
View File
@@ -23,6 +23,7 @@ use serde::{Deserialize, Serialize};
use crate::{
modules::{
duckdb::init::duckdb,
error::{code::ErrorCode, BichonResult},
indexer::{envelope::Envelope, manager::ENVELOPE_INDEX_MANAGER},
rest::response::DataPage,
@@ -78,6 +79,17 @@ impl SearchRequest {
ErrorCode::InvalidParameter
));
}
if let Some(ref pattern) = self.filter.text {
if let Err(_) = duckdb()?.validate_regex(pattern) {
return Err(raise_error!(
"Invalid search pattern: The regular expression is not supported by DuckDB."
.into(),
ErrorCode::InvalidParameter
));
}
}
Ok(())
}
}