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

Avoid slicing a string in DocParsingError #1339

Closed
fmassot opened this issue Apr 14, 2022 · 1 comment · Fixed by #1559
Closed

Avoid slicing a string in DocParsingError #1339

fmassot opened this issue Apr 14, 2022 · 1 comment · Fixed by #1559

Comments

@fmassot
Copy link
Contributor

fmassot commented Apr 14, 2022

Done here: https://github.com/quickwit-oss/tantivy/blob/main/src/schema/schema.rs#L402-L412

Better with invalid_json.chars().take(20) :)

@fmassot fmassot changed the title Avoid slicing a string Avoid slicing a string in DocParsingError Apr 14, 2022
@waywardmonkeys
Copy link
Contributor

The version for those line numbers would be

impl DocParsingError {
/// Builds a NotJson DocParsingError
fn invalid_json(invalid_json: &str) -> Self {
let sample_json: String = if invalid_json.len() < 20 {
invalid_json.to_string()
} else {
format!("{:?}...", &invalid_json[0..20])
};
DocParsingError::InvalidJson(sample_json)
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants