Skip to content

Commit

Permalink
Merge pull request #8 from zkemail/fix/clave-depl
Browse files Browse the repository at this point in the history
fix: Clave Deployment
  • Loading branch information
Bisht13 authored Oct 22, 2024
2 parents 6d30800 + cdf3e55 commit 8c7ed1c
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 50 deletions.
80 changes: 40 additions & 40 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions src/command_templates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,12 @@ pub fn extract_template_vals_from_command(
templates: Vec<String>,
) -> Result<Vec<TemplateValue>, anyhow::Error> {
// Skip to text/html part
let re = Regex::new(r"(?s)Content-Type:\s*text/html;.*?\r?\n\r?\n(.*?)(?:--\S+|$)").unwrap();
let caps = re.captures(input).unwrap();
let input = caps.get(1).unwrap().as_str();
let mut input = input;
let re = Regex::new(r"(?s)Content-Type:\s*text/html;").unwrap();
if let Some(matched) = re.find(input) {
let text_html_idx = matched.end();
input = &input[text_html_idx..];
}

// Convert the template to a regex pattern, escaping necessary characters and replacing placeholders
let pattern = templates
Expand Down
14 changes: 7 additions & 7 deletions src/parse_email.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,11 +180,11 @@ impl ParsedEmail {
pub fn get_invitation_code(&self, ignore_body_hash_check: bool) -> Result<String> {
let regex_config = serde_json::from_str(include_str!("../regexes/invitation_code.json"))?;
if ignore_body_hash_check {
let idxes = extract_substr_idxes(&self.canonicalized_header, &regex_config)?[0];
let idxes = extract_substr_idxes(&self.canonicalized_header, &regex_config, false)?[0];
let str = self.canonicalized_header[idxes.0..idxes.1].to_string();
Ok(str)
} else {
let idxes = extract_substr_idxes(&self.cleaned_body, &regex_config)?[0];
let idxes = extract_substr_idxes(&self.cleaned_body, &regex_config, false)?[0];
let str = self.cleaned_body[idxes.0..idxes.1].to_string();
Ok(str)
}
Expand All @@ -197,10 +197,10 @@ impl ParsedEmail {
) -> Result<(usize, usize)> {
let regex_config = serde_json::from_str(include_str!("../regexes/invitation_code.json"))?;
if ignore_body_hash_check {
let idxes = extract_substr_idxes(&self.canonicalized_header, &regex_config)?[0];
let idxes = extract_substr_idxes(&self.canonicalized_header, &regex_config, false)?[0];
Ok(idxes)
} else {
let idxes = extract_substr_idxes(&self.cleaned_body, &regex_config)?[0];
let idxes = extract_substr_idxes(&self.cleaned_body, &regex_config, false)?[0];
Ok(idxes)
}
}
Expand Down Expand Up @@ -235,12 +235,12 @@ impl ParsedEmail {
if ignore_body_hash_check {
Ok("".to_string())
} else {
match extract_substr_idxes(&self.canonicalized_body, &regex_config) {
match extract_substr_idxes(&self.canonicalized_body, &regex_config, false) {
Ok(idxes) => {
let str = self.canonicalized_body[idxes[0].0..idxes[0].1].to_string();
Ok(str.replace("=\r\n", ""))
}
Err(_) => match extract_substr_idxes(&self.cleaned_body, &regex_config) {
Err(_) => match extract_substr_idxes(&self.cleaned_body, &regex_config, false) {
Ok(idxes) => {
let str = self.cleaned_body[idxes[0].0..idxes[0].1].to_string();
Ok(str)
Expand All @@ -257,7 +257,7 @@ impl ParsedEmail {
if ignore_body_hash_check {
Ok((0, 0))
} else {
let idxes = extract_substr_idxes(&self.cleaned_body, &regex_config)?[0];
let idxes = extract_substr_idxes(&self.cleaned_body, &regex_config, false)?[0];
Ok(idxes)
}
}
Expand Down

0 comments on commit 8c7ed1c

Please sign in to comment.