crabmail

Static HTML email archive viewer in Rust
git clone git://git.alexwennerberg.com/crabmail
Log | Files | Refs | README | LICENSE

commit 56edf7b1c61b38dd15ea815b489ae9e34b9e5dfa
parent f2e89cf3ff1d0c31d2ab3dbad18a06ffb00b204c
Author: alex wennerberg <alex@alexwennerberg.com>
Date:   Thu,  6 Jan 2022 21:28:03 -0800

Replace sha3 with escaped id

Diffstat:
MCargo.lock | 68--------------------------------------------------------------------
MCargo.toml | 4----
Msrc/main.rs | 22++++------------------
3 files changed, 4 insertions(+), 90 deletions(-)

diff --git a/Cargo.lock b/Cargo.lock @@ -15,15 +15,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" [[package]] -name = "block-buffer" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1d36a02058e76b040de25a4464ba1c80935655595b661505c8b39b664828b95" -dependencies = [ - "generic-array", -] - -[[package]] name = "cfg-if" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -50,31 +41,10 @@ dependencies = [ "mailparse", "nanohtml2text", "once_cell", - "sha3", "urlencoding", ] [[package]] -name = "crypto-common" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "683d6b536309245c849479fba3da410962a43ed8e51c26b729208ec0ac2798d0" -dependencies = [ - "generic-array", -] - -[[package]] -name = "digest" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b697d66081d42af4fba142d56918a3cb21dc8eb63372c6b85d14f44fb9c5979b" -dependencies = [ - "block-buffer", - "crypto-common", - "generic-array", -] - -[[package]] name = "encoding_rs" version = "0.8.30" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -84,16 +54,6 @@ dependencies = [ ] [[package]] -name = "generic-array" -version = "0.14.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "501466ecc8a30d1d3b7fc9229b122b2ce8ed6e9d9223f1138d4babb253e51817" -dependencies = [ - "typenum", - "version_check", -] - -[[package]] name = "gethostname" version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -110,12 +70,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8371fb981840150b1a54f7cb117bf6699f7466a1d4861daac33bc6fe2b5abea0" [[package]] -name = "keccak" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67c21572b4949434e4fc1e1978b99c5f77064153c59d998bf13ecd96fb5ecba7" - -[[package]] name = "libc" version = "0.2.112" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -176,34 +130,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fee2dce59f7a43418e3382c766554c614e06a552d53a8f07ef499ea4b332c0f" [[package]] -name = "sha3" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31f935e31cf406e8c0e96c2815a5516181b7004ae8c5f296293221e9b1e356bd" -dependencies = [ - "digest", - "keccak", -] - -[[package]] -name = "typenum" -version = "1.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987" - -[[package]] name = "urlencoding" version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "68b90931029ab9b034b300b797048cf23723400aa757e8a2bfb9d748102f9821" [[package]] -name = "version_check" -version = "0.9.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" - -[[package]] name = "winapi" version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" diff --git a/Cargo.toml b/Cargo.toml @@ -7,9 +7,6 @@ edition = "2018" [features] default = [] -[lib] -proc-macro = true - [dependencies] anyhow = "1.0" horrorshow = "0.8" @@ -17,6 +14,5 @@ linkify = "0.8" mailparse = "0.13" maildir = "0.5.0" once_cell = "1.9" -sha3 = "0.10" urlencoding = "2.1" nanohtml2text = "0.1.0" diff --git a/src/main.rs b/src/main.rs @@ -12,10 +12,6 @@ use std::str; extern crate horrorshow; use mailparse::*; -use sha3::{ - digest::{ExtendableOutput, Update, XofReader}, - Shake128, -}; use std::collections::{HashMap, HashSet}; use std::fs::File; use std::io::prelude::*; @@ -29,7 +25,7 @@ mod time; mod utils; // TODO be more clear about the expected input types -// maildi +// maildir // Not a "raw email" struct, but an email object that can be represented by // crabmail. @@ -380,20 +376,10 @@ impl Email { url.into() } - // Build hash string from message ID - // This allows for a stable, url-friendly filename + // TODO rename + // pub fn hash(&self) -> String { - let mut hasher = Shake128::default(); - hasher.update(&self.id.as_bytes()); - let mut reader = hasher.finalize_xof(); - let mut res1 = [0u8; 6]; - XofReader::read(&mut reader, &mut res1); - let mut out = String::new(); - for byte in &res1 { - use std::fmt::Write; // TODO - write!(out, "{:02x}", byte).unwrap(); - } - return out; + self.id.replace("/", ";") } }