From 7d8ca4f86de72284649ca1e4d69b4215b3a60c27 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)?;