Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix printing possible plaintexts #102

Merged
merged 4 commits into from
Nov 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions deny.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ ignore = [
# ansi_term is unmaintained, but it does exactly what it needs to and no more
# so no reason to change just for the sake of it
"RUSTSEC-2021-0139",
# atty is used in criterion, ignoring it until they update
"RUSTSEC-2021-0145"
]

[licenses]
Expand Down
10 changes: 7 additions & 3 deletions src/checkers/english.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ impl Check for Checker<EnglishChecker> {
}

fn check(&self, input: &str) -> CheckResult {
let original_input = input;
// Normalise the string
let input = normalise_string(input);
trace!("Checking English for sentence {}", input);
Expand Down Expand Up @@ -65,16 +66,19 @@ impl Check for Checker<EnglishChecker> {
);
// TODO: We are also typecasting to f64 instead of usize, which costs CPU cycles.
if words_found / (input.split(' ').count()) as f64 > PLAINTEXT_DETECTION_PERCENTAGE {
debug!("Found {} words in {}", words_found, input);
debug!("Returning from English chekcer successfully with {}", input);
debug!("Found {} words in {}", words_found, original_input);
debug!(
"Returning from English chekcer successfully with {}",
original_input
);
plaintext_found = true;
break;
}
}

CheckResult {
is_identified: plaintext_found,
text: input.to_string(),
text: original_input.to_string(),
checker_name: self.name,
checker_description: self.description,
description: filename.to_string(),
Expand Down