Skip to content

Commit

Permalink
Fixed: MIME edge case for parsing multi MIME lines that are merged in…
Browse files Browse the repository at this point in the history
…to a single line.
  • Loading branch information
DK26 committed Jul 26, 2021
1 parent aa945df commit 815f814
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
13 changes: 7 additions & 6 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ fn arg_matches<'a>() -> ArgMatches<'a> {
let about = format!("Fast, lightweight RESTful API services for processing, parsing & modifying UTF-8 text messages.
\nAuthor: {}\nSource: https://github.com/DK26/fast-webhooks", env!("CARGO_PKG_AUTHORS"));

clap::App::new("Fast-Webhooks")
clap::App::new(env!("CARGO_PKG_NAME"))
.version(env!("CARGO_PKG_VERSION"))
.about(about.as_str())
.arg(
Expand Down Expand Up @@ -131,7 +131,12 @@ fn arg_matches<'a>() -> ArgMatches<'a> {

lazy_static! {

static ref CFG: Config = cfglib::init_cfg(arg_matches());
static ref CFG: Config = cfglib::init_cfg({
let cfg = arg_matches();
println!("{} {}", env!("CARGO_PKG_NAME"), env!("CARGO_PKG_VERSION"));
log::info!("Initializing service...");
cfg
});

static ref PATTERNS_CACHE: RwLock<PatternsCache> = {

Expand All @@ -152,10 +157,6 @@ async fn main() -> std::io::Result<()> {
.with_level(log::LevelFilter::Info)
.init().unwrap();

// FIXME: This seem to appear during `clap` help menus.
// TODO: Print version
log::info!("Initializing service...");

// Configurations
// Service
log::debug!("listen = {}", CFG.service.listen);
Expand Down
6 changes: 4 additions & 2 deletions src/services.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ pub async fn decode_base64_charset(web::Path((charset,)): web::Path<(String,)>,
#[post("/decode_mime_header")]
pub async fn decode_mime_header(req_body: String) -> impl Responder {

let normalized_req_body = utils::normalize_mime(&req_body);
let normalized_req_body = utils::normalize_mime(&req_body)
.replace(" =?", "\r\n=?")
.replace("?= ", "?=\r\n");

// let response: String = normalized_req_body.lines()
// .map(|x| {
Expand All @@ -92,7 +94,7 @@ pub async fn decode_mime_header(req_body: String) -> impl Responder {
let mut response = String::new();

for line in normalized_req_body.lines() {

let trimmed_line = line.trim_start();

if trimmed_line.starts_with("=?") && trimmed_line.ends_with("?=") {
Expand Down

0 comments on commit 815f814

Please sign in to comment.