aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKlimperfix2025-10-03 12:37:16 +0200
committerKlimperfix2025-10-03 12:37:16 +0200
commitdfb7edde13ca39af3e23b80e40272e02aa093919 (patch)
treeb5f3894798efe613b3a592fe3aa0ff398db5948e
parent7350c7382bda85618c3dae1d74cc8cbe7ddd4b9d (diff)
downloadbibiman-dfb7edde13ca39af3e23b80e40272e02aa093919.tar.gz
bibiman-dfb7edde13ca39af3e23b80e40272e02aa093919.zip
Sanitization hooked into bibiman.
-rw-r--r--src/bibiman/bibisetup.rs27
1 files changed, 24 insertions, 3 deletions
diff --git a/src/bibiman/bibisetup.rs b/src/bibiman/bibisetup.rs
index 3bcb717..8466169 100644
--- a/src/bibiman/bibisetup.rs
+++ b/src/bibiman/bibisetup.rs
@@ -26,6 +26,7 @@ use std::{fs, path::PathBuf};
use walkdir::WalkDir;
use crate::app;
+use crate::bibiman::sanitize::sanitize_one;
use crate::cliargs::{self};
use crate::config::BibiConfig;
@@ -294,11 +295,28 @@ impl BibiSetup {
let filepaths: (Option<Vec<OsString>>, bool) =
{ Self::get_filepath(k, bibliography, &mut pdf_files) };
+ // bibiman will sanitize some fields at this point,
+ // this may cause longer startup-load-times.
+ //
+ // It may be better to sanitize them somewhere else, so bibiman
+ // does not loose the original text-information including the
+ // LaTeX macros present in the bibfile. From here on, they will be
+ // gone.
+ //
+ // The following fields are going to be sanitized:
+ //
+ // - title
+ // - subtitle
+ // - abstract_text
+ //
+ // TODO: Once the final decision to implement the sanitization at
+ // this point, one could write a constructor for the BibiData struct
+ // which handles the sanitization.
BibiData {
id: i as u32,
authors: Self::get_authors(k, bibliography),
short_author: String::new(),
- title: Self::get_title(k, bibliography),
+ title: sanitize_one(&Self::get_title(k, bibliography)),
year: Self::get_year(k, bibliography),
custom_field: (
cfg.general.custom_column.clone(),
@@ -306,11 +324,14 @@ impl BibiSetup {
),
keywords: Self::get_keywords(k, bibliography),
citekey: k.to_owned(),
- abstract_text: Self::get_abstract(k, bibliography),
+ abstract_text: sanitize_one(&Self::get_abstract(k, bibliography)),
doi_url: Self::get_weblink(k, bibliography),
filepath: filepaths.0,
file_field: filepaths.1,
- subtitle: Self::get_subtitle(k, bibliography),
+ subtitle: match Self::get_subtitle(k, bibliography) {
+ None => None,
+ Some(x) => Some(sanitize_one(&x)),
+ },
notes: if note_files.is_some() {
Self::get_notepath(k, &mut note_files, &ext)
} else {