Trim the secret read by the matrix.secret_file configuration option (#4961)

This commit is contained in:
Quentin Gliech
2025-09-12 15:36:19 +02:00
committed by GitHub

View File

@@ -131,7 +131,11 @@ impl MatrixConfig {
/// Returns an error when the shared secret could not be read from file.
pub async fn secret(&self) -> anyhow::Result<String> {
Ok(match &self.secret {
Secret::File(path) => tokio::fs::read_to_string(path).await?,
Secret::File(path) => {
let raw = tokio::fs::read_to_string(path).await?;
// Trim the secret when read from file to match Synapse's behaviour
raw.trim().to_string()
}
Secret::Value(secret) => secret.clone(),
})
}