Browse Source

conf.rs: reject unknown configuration options

Closes #11
memfd
Manos Pitsidianakis 3 years ago
parent
commit
52bcecfd4a
Signed by untrusted user: epilys GPG Key ID: 73627C2F690DF710
  1. 1
      config_macros.rs
  2. 3
      src/conf.rs
  3. 1
      src/conf/composing.rs
  4. 1
      src/conf/listing.rs
  5. 1
      src/conf/notifications.rs
  6. 7
      src/conf/overrides.rs
  7. 1
      src/conf/pager.rs
  8. 1
      src/conf/pgp.rs
  9. 1
      src/conf/shortcuts.rs
  10. 1
      src/conf/tags.rs
  11. 2
      src/conf/terminal.rs
  12. 3
      src/conf/themes.rs

1
config_macros.rs

@ -134,6 +134,7 @@ use super::*;
let literal_struct = quote! {
#[derive(Debug, Serialize, Deserialize, Clone)]
#[serde(deny_unknown_fields)]
pub struct #override_ident {
#(#field_tokentrees),*
}

3
src/conf.rs

@ -108,6 +108,7 @@ macro_rules! mailbox_settings {
}
#[derive(Default, Debug, Clone, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct MailUIConf {
#[serde(default)]
pub pager: PagerSettingsOverride,
@ -191,6 +192,7 @@ impl FileAccount {
}
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct FileSettings {
pub accounts: HashMap<String, FileAccount>,
#[serde(default)]
@ -821,6 +823,7 @@ mod pp {
}
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct LogSettings {
#[serde(default)]
log_file: Option<PathBuf>,

1
src/conf/composing.rs

@ -25,6 +25,7 @@ use std::collections::HashMap;
/// Settings for writing and sending new e-mail
#[derive(Debug, Serialize, Deserialize, Clone)]
#[serde(deny_unknown_fields)]
pub struct ComposingSettings {
/// A command to pipe new emails to
/// Required

1
src/conf/listing.rs

@ -25,6 +25,7 @@ use melib::{MeliError, Result};
/// Settings for mail listings
#[derive(Debug, Deserialize, Clone, Serialize)]
#[serde(deny_unknown_fields)]
pub struct ListingSettings {
/// Number of context lines when going to next page.
/// Default: 0

1
src/conf/notifications.rs

@ -23,6 +23,7 @@ use super::default_vals::{internal_value_false, none};
/// Settings for the notifications function.
#[derive(Debug, Serialize, Deserialize, Clone)]
#[serde(deny_unknown_fields)]
pub struct NotificationsSettings {
/// A command to pipe notifications through
/// Default: None

7
src/conf/overrides.rs

@ -23,6 +23,7 @@
use super::*;
#[derive(Debug, Serialize, Deserialize, Clone)]
#[serde(deny_unknown_fields)]
pub struct PagerSettingsOverride {
#[doc = " Number of context lines when going to next page."]
#[doc = " Default: 0"]
@ -94,6 +95,7 @@ impl Default for PagerSettingsOverride {
}
#[derive(Debug, Serialize, Deserialize, Clone)]
#[serde(deny_unknown_fields)]
pub struct ListingSettingsOverride {
#[doc = " Number of context lines when going to next page."]
#[doc = " Default: 0"]
@ -131,6 +133,7 @@ impl Default for ListingSettingsOverride {
}
#[derive(Debug, Serialize, Deserialize, Clone)]
#[serde(deny_unknown_fields)]
pub struct NotificationsSettingsOverride {
#[doc = " A command to pipe notifications through"]
#[doc = " Default: None"]
@ -161,6 +164,7 @@ impl Default for NotificationsSettingsOverride {
}
#[derive(Debug, Serialize, Deserialize, Clone)]
#[serde(deny_unknown_fields)]
pub struct ShortcutsOverride {
#[serde(default)]
pub general: Option<GeneralShortcuts>,
@ -199,6 +203,7 @@ impl Default for ShortcutsOverride {
}
#[derive(Debug, Serialize, Deserialize, Clone)]
#[serde(deny_unknown_fields)]
pub struct ComposingSettingsOverride {
#[doc = " A command to pipe new emails to"]
#[doc = " Required"]
@ -235,6 +240,7 @@ impl Default for ComposingSettingsOverride {
}
#[derive(Debug, Serialize, Deserialize, Clone)]
#[serde(deny_unknown_fields)]
pub struct TagsSettingsOverride {
#[serde(deserialize_with = "tag_color_de")]
#[serde(default)]
@ -253,6 +259,7 @@ impl Default for TagsSettingsOverride {
}
#[derive(Debug, Serialize, Deserialize, Clone)]
#[serde(deny_unknown_fields)]
pub struct PGPSettingsOverride {
#[doc = " auto verify signed e-mail according to RFC3156"]
#[serde(alias = "auto-verify-signatures")]

1
src/conf/pager.rs

@ -28,6 +28,7 @@ use melib::{MeliError, Result, ToggleFlag};
/// Settings for the pager function.
#[derive(Debug, Deserialize, Clone, Serialize)]
#[serde(deny_unknown_fields)]
pub struct PagerSettings {
/// Number of context lines when going to next page.
/// Default: 0

1
src/conf/pgp.rs

@ -23,6 +23,7 @@ use super::default_vals::*;
/// Settings for digital signing and encryption
#[derive(Debug, Deserialize, Clone, Serialize)]
#[serde(deny_unknown_fields)]
pub struct PGPSettings {
/// auto verify signed e-mail according to RFC3156
#[serde(default = "true_val", alias = "auto-verify-signatures")]

1
src/conf/shortcuts.rs

@ -35,6 +35,7 @@ macro_rules! shortcut {
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct Shortcuts {
#[serde(default)]
pub general: GeneralShortcuts,

1
src/conf/tags.rs

@ -29,6 +29,7 @@ use std::collections::{hash_map::DefaultHasher, HashMap, HashSet};
use std::hash::Hasher;
#[derive(Debug, Deserialize, Clone, Serialize)]
#[serde(deny_unknown_fields)]
pub struct TagsSettings {
#[serde(default, deserialize_with = "tag_color_de")]
pub colors: HashMap<u64, Color>,

2
src/conf/terminal.rs

@ -28,7 +28,7 @@ use melib::{MeliError, Result, ToggleFlag};
/// Settings for terminal display
#[derive(Debug, Deserialize, Clone, Serialize)]
#[serde(default)]
#[serde(default, deny_unknown_fields)]
pub struct TerminalSettings {
/// light, dark
pub theme: String,

3
src/conf/themes.rs

@ -306,6 +306,7 @@ const DEFAULT_KEYS: &[&str] = &[
/// `ThemeAttributeInner` but with the links resolved.
#[derive(Debug, PartialEq, Eq, Clone, Default, Copy, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct ThemeAttribute {
pub fg: Color,
pub bg: Color,
@ -314,6 +315,7 @@ pub struct ThemeAttribute {
/// Holds {fore,back}ground color and terminal attribute values.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct ThemeAttributeInner {
#[serde(default)]
fg: ThemeValue<Color>,
@ -799,6 +801,7 @@ impl<'de> Deserialize<'de> for Themes {
rest: ThemeAttributeInnerOptions,
}
#[derive(Deserialize, Default)]
#[serde(deny_unknown_fields)]
struct ThemeAttributeInnerOptions {
#[serde(default)]
fg: Option<ThemeValue<Color>>,

Loading…
Cancel
Save