BREAKING CHANGE(smtp-client): Replace the legacy TypeScript SMTP client with a new Rust-based SMTP client and IPC bridge for outbound delivery
This commit is contained in:
@@ -7,14 +7,11 @@ license.workspace = true
|
||||
[dependencies]
|
||||
mailer-core = { path = "../mailer-core" }
|
||||
mail-auth.workspace = true
|
||||
ring.workspace = true
|
||||
thiserror.workspace = true
|
||||
tracing.workspace = true
|
||||
serde.workspace = true
|
||||
serde_json.workspace = true
|
||||
tokio.workspace = true
|
||||
hickory-resolver.workspace = true
|
||||
ipnet.workspace = true
|
||||
rustls-pki-types.workspace = true
|
||||
psl.workspace = true
|
||||
regex.workspace = true
|
||||
|
||||
@@ -111,16 +111,18 @@ static MACRO_DOCUMENT_EXTENSIONS: LazyLock<Vec<&'static str>> = LazyLock::new(||
|
||||
// HTML helpers
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
/// Regexes for HTML text extraction (compiled once via LazyLock).
|
||||
static HTML_STYLE_RE: LazyLock<Regex> =
|
||||
LazyLock::new(|| Regex::new(r"(?is)<style[^>]*>.*?</style>").unwrap());
|
||||
static HTML_SCRIPT_RE: LazyLock<Regex> =
|
||||
LazyLock::new(|| Regex::new(r"(?is)<script[^>]*>.*?</script>").unwrap());
|
||||
static HTML_TAG_RE: LazyLock<Regex> = LazyLock::new(|| Regex::new(r"<[^>]+>").unwrap());
|
||||
|
||||
/// Strip HTML tags and decode common entities to produce plain text.
|
||||
fn extract_text_from_html(html: &str) -> String {
|
||||
// Remove style and script blocks first
|
||||
let no_style = Regex::new(r"(?is)<style[^>]*>.*?</style>").unwrap();
|
||||
let no_script = Regex::new(r"(?is)<script[^>]*>.*?</script>").unwrap();
|
||||
let no_tags = Regex::new(r"<[^>]+>").unwrap();
|
||||
|
||||
let text = no_style.replace_all(html, " ");
|
||||
let text = no_script.replace_all(&text, " ");
|
||||
let text = no_tags.replace_all(&text, " ");
|
||||
let text = HTML_STYLE_RE.replace_all(html, " ");
|
||||
let text = HTML_SCRIPT_RE.replace_all(&text, " ");
|
||||
let text = HTML_TAG_RE.replace_all(&text, " ");
|
||||
|
||||
text.replace(" ", " ")
|
||||
.replace("<", "<")
|
||||
|
||||
Reference in New Issue
Block a user