mirror of
https://github.com/rustmailer/bichon.git
synced 2026-08-03 07:48:34 +02:00
add regex pattern validation via DuckDB
This commit is contained in:
@@ -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(())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user