model: geometry names up to 64 KiB everywhere, so long persistent face names mesh

Persistent names grow with a design's split history; opening accepted them but mesh tags, sets
and loads capped geometry names at 256 characters. One cap (64 KiB, against hostile input)
now holds for geometry references, partitions and saved views.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UhhZMBTviDQxZvwnyP89fo
This commit is contained in:
jyvikoandClaude Opus 5.5 authored and Irakli Kourtis committed 2026-10-15 10:09:04 -04:00
1 parent 7a078b1c04
commit 750f5f5a61
4 files changed
+42 -10

No files matched your search

+3 -4
View File
@@ -11,14 +11,13 @@ use std::collections::BTreeMap;
use serde::{Deserialize, Serialize};
use crate::geometry::MAX_GEOMETRY_NAME_LEN;
use crate::{Error, Model, Result, check_name, context, insert_new, not_in_use, remove_existing, replace_existing};
/// Most partitions a model holds.
pub const MAX_PARTITIONS: usize = 256;
/// Most bodies one partition names.
pub const MAX_PARTITION_BODIES: usize = 1000;
/// Longest body name a partition holds.
const MAX_BODY_NAME: usize = 256;
/// A datum plane, axis or point.
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)]
@@ -163,8 +162,8 @@ impl Model {
return Err(invalid(format!("at most {MAX_PARTITION_BODIES} bodies")));
}
for (i, b) in partition.bodies.iter().enumerate() {
if b.trim().is_empty() || b.len() > MAX_BODY_NAME {
return Err(invalid(format!("body names are 1 to {MAX_BODY_NAME} characters")));
if b.trim().is_empty() || b.len() > MAX_GEOMETRY_NAME_LEN {
return Err(invalid(format!("body names are 1 to {MAX_GEOMETRY_NAME_LEN} bytes")));
}
if partition.bodies.get(..i).is_some_and(|before| before.contains(b)) {
return Err(invalid(format!("body `{b}` is listed twice")));
+8 -4
View File
@@ -16,9 +16,13 @@ use serde::{Deserialize, Serialize};
use crate::{Error, Model, Result};
/// Longest body or entity name accepted (persistent names can be long; they are not written to
/// decks as such).
pub const MAX_GEOMETRY_NAME_LEN: usize = 256;
/// Longest body or entity name accepted, in bytes. Persistent names grow with the design's split
/// history (a face cut by a groove, then split by joined bosses, names every step), so a real
/// design can produce names of hundreds or thousands of characters; this cap only bounds hostile
/// input (control channel, model files). The same cap holds wherever a geometry name is taken:
/// opening, mesh tags, sets, ties, loads, partitions and saved views. Names are not written to
/// decks as such.
pub const MAX_GEOMETRY_NAME_LEN: usize = 64 * 1024;
/// Most distinct geometry entities a mesh can be tagged with.
pub const MAX_ENTITIES: usize = 1_000_000;
@@ -114,7 +118,7 @@ impl From<GeometryRef> for GeometryRefRepr {
fn check_geometry_name(what: &str, name: &str) -> Result<()> {
if name.is_empty() || name.len() > MAX_GEOMETRY_NAME_LEN || name.chars().any(char::is_control) {
let shown: String = name.chars().take(64).filter(|c| !c.is_control()).collect();
return Err(Error::Invalid(format!("{what} name `{shown}` must be 1 to {MAX_GEOMETRY_NAME_LEN} characters with no control characters")));
return Err(Error::Invalid(format!("{what} name `{shown}` must be 1 to {MAX_GEOMETRY_NAME_LEN} bytes with no control characters")));
}
Ok(())
}