From 4e281026a0ee22099065261b010b8d2e87f3ffc8 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Mon, 4 Dec 2023 15:16:05 +1000 Subject: [PATCH] Catch NaNs in FSRS weights Users pasting in weights from the old scheduler were leaving the outer square brackets in, causing the first and last numbers to be parsed as NaN. --- rslib/src/deckconfig/update.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/rslib/src/deckconfig/update.rs b/rslib/src/deckconfig/update.rs index 0ee29c88f..70c26ccfe 100644 --- a/rslib/src/deckconfig/update.rs +++ b/rslib/src/deckconfig/update.rs @@ -145,7 +145,13 @@ impl Collection { // add/update provided configs for conf in &mut req.configs { let weight_len = conf.inner.fsrs_weights.len(); - if weight_len != 0 && weight_len != 17 { + if weight_len == 17 { + for i in 0..17 { + if !conf.inner.fsrs_weights[i].is_normal() { + return Err(AnkiError::FsrsWeightsInvalid); + } + } + } else if weight_len != 0 { return Err(AnkiError::FsrsWeightsInvalid); } self.add_or_update_deck_config(conf)?;