open-standards/wai/http-conformance/falsify/budget-unlabelled-escapes.patch
2026-10-06 14:03:26 -04:00

15 lines
881 B
Diff

# must fail: abr_budget_unlabelled_choice
# an unlabelled choice leaves the budget unapplied (abr::clamp_to_budget)
diff --git a/wai/wai-rs/src/http_binding/abr.rs b/wai/wai-rs/src/http_binding/abr.rs
index cc9cd96a..20028eea 100644
--- a/wai/wai-rs/src/http_binding/abr.rs
+++ b/wai/wai-rs/src/http_binding/abr.rs
@@ -392,7 +392,7 @@ pub fn clamp_to_budget(s: &AbrState, choice: usize) -> (usize, Budget) {
let Some(b) = s.joule_budget_micro else { return (choice, Budget::NotSet) };
let n = s.option_bytes.len().max(choice + 1);
let fig = |k: usize| if k < n { s.option_joules_micro.get(k).copied().flatten() } else { None };
- if (0..n).all(|k| fig(k).is_none()) {
+ if (0..n).all(|k| fig(k).is_none()) || fig(choice).is_none() {
return (choice, Budget::NotApplied);
}
match (0..=choice).rev().find(|&k| fig(k).is_some_and(|j| j <= b)) {