fix(anatomy): V1-2.2 refuse arc radii browsers read as zero
Security review of the interior rule: an arc radius below f32 precision was scaled by the core to a half disc the browser never fills. Nonzero radii below 2^-20 make the path unreadable; arcs add their f32 drift to the chord deviation; tracing stops past the vertex cap; a path without outline is refused.
This commit is contained in:
1 parent
8dd2d78d38
commit
03be75beed
6 files changed
+126
-29
No files matched your search
@@ -20,11 +20,15 @@ use serde_json::{Value, json};
|
||||
|
||||
const FIXTURE: &str = "apps/app/e2e/fixtures/interior-probe.json";
|
||||
const THIN: &str = "annotation.geometry.interior_too_small";
|
||||
const UNREADABLE: &str = "annotation.geometry.out_of_frame";
|
||||
const PHONE: &str = "0 0 286 310";
|
||||
|
||||
/// The widest disc of a shape, measured to a thousandth of a unit: centre and radius.
|
||||
/// The widest disc of a shape, measured to a thousandth of a unit: centre and radius; none for
|
||||
/// path data the core does not read.
|
||||
fn widest(geometry: &Geometry) -> Value {
|
||||
let outline = geometry_outline(geometry, 0.001).unwrap();
|
||||
let Some(outline) = geometry_outline(geometry, 0.001) else {
|
||||
return Value::Null;
|
||||
};
|
||||
let search = Search {
|
||||
floor: 0.0,
|
||||
enough: f64::INFINITY,
|
||||
@@ -185,6 +189,12 @@ fn cases() -> Vec<Value> {
|
||||
polygon(&[[40.0, 45.716], [46.6, 45.716], [43.3, 40.0]]),
|
||||
plain,
|
||||
),
|
||||
// A radius browsers read as zero (`f32`), where `f64` would scale it to a half disc.
|
||||
case(
|
||||
"arc-radius-1e-49",
|
||||
path("M40 50A1e-49 1e-49 0 0 1 90 50Z"),
|
||||
plain,
|
||||
),
|
||||
]
|
||||
}
|
||||
|
||||
@@ -211,7 +221,7 @@ fn equine() -> Vec<Value> {
|
||||
fn the_interior_probe_is_current() {
|
||||
let cases = cases();
|
||||
for c in &cases {
|
||||
let refused = c["codes"] == json!([THIN]);
|
||||
let refused = c["codes"] == json!([THIN]) || c["codes"] == json!([UNREADABLE]);
|
||||
assert!(c["accepted"] == json!(true) || refused, "{}", c["name"]);
|
||||
}
|
||||
let probe = json!({
|
||||
|
||||
@@ -204,7 +204,7 @@ fn the_equine_threshold_falls_on_the_caudal_zone_then_the_junctions() {
|
||||
found
|
||||
};
|
||||
let pair = |id: &str, code: &str| (id.to_owned(), code.to_owned());
|
||||
assert!(small(1.23).is_empty());
|
||||
assert!(small(1.235).is_empty(), "4.009 px");
|
||||
assert_eq!(small(1.24), [pair("caudal", THIN)]);
|
||||
let (_, failures) = judged(&text, &[(HORSE_ID, &scaled_horse(1.24))]);
|
||||
assert_eq!(
|
||||
@@ -401,6 +401,10 @@ fn path_numbers_past_the_frame_magnitude_are_refused() {
|
||||
"M1 1A1e39 1e39 0 0 1 3 1L3 3L1 3Z",
|
||||
"M1 1A1 1 1e39 0 1 3 1L3 3L1 3Z",
|
||||
"M1 1L3 1L3 3L-1e39 3Z",
|
||||
// An arc radius below 2^-20 other than zero (security review of the interior rule):
|
||||
// a browser reads it as zero or draws nothing, `f64` would scale it to a half disc.
|
||||
"M1 1A1e-49 1e-49 0 0 1 3 1Z",
|
||||
"M1 1A1e-20 1e-20 0 0 1 3 1Z",
|
||||
] {
|
||||
assert_eq!(main(d), [OUT_OF_FRAME], "{d}");
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user