mirror of
https://github.com/mailscope/kumomta.git
synced 2026-10-08 08:02:24 +00:00
spf: avoid wrong kind of json -> string conversion
When populating ehlo_domain in particular, we were using the json Value::to_string() impl which produces a json-serialized string which includes quotes. This is a bit of a foot-gun, so let's add a get_meta_string method to ConnectionMetaData to parallel the equivalent Message::get_meta_string method.
This commit is contained in:
@@ -2965,6 +2965,11 @@ impl ConnectionMetaData {
|
||||
meta.get(name.as_ref()).cloned()
|
||||
}
|
||||
|
||||
pub fn get_meta_string<N: AsRef<str>>(&self, name: N) -> Option<String> {
|
||||
self.get_meta(name)
|
||||
.and_then(|v| v.as_str().map(|s| s.to_string()))
|
||||
}
|
||||
|
||||
pub fn clone_inner(&self) -> serde_json::Value {
|
||||
self.map.lock().clone()
|
||||
}
|
||||
|
||||
@@ -26,8 +26,8 @@ pub fn register<'lua>(lua: &'lua Lua) -> anyhow::Result<()> {
|
||||
.and_then(|v| SocketAddr::from_str(v.as_str()?).ok())
|
||||
.expect("`received_from` is always set, and always to a value representing a `SocketAddr`");
|
||||
|
||||
let ehlo_domain = meta.get_meta("ehlo_domain").map(|s| s.to_string());
|
||||
let relaying_host_name = meta.get_meta("hostname").map(|s| s.to_string());
|
||||
let ehlo_domain = meta.get_meta_string("ehlo_domain");
|
||||
let relaying_host_name = meta.get_meta_string("hostname");
|
||||
|
||||
let resolver = dns_resolver::get_resolver();
|
||||
let result = CheckHostParams {
|
||||
|
||||
Reference in New Issue
Block a user