Parameters: check document size before naming inputs
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AS5Tn3xieewUSg3uxrMVdL
This commit is contained in:
1 parent
f0cfeba59b
commit
e8de4d9e69
1 file changed
+4
-3
@@ -734,15 +734,16 @@ impl Document {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn from_json(s: &str) -> Result<Document> {
|
pub fn from_json(s: &str) -> Result<Document> {
|
||||||
let d: Document = serde_json::from_str(s).map_err(|e| DocError::Invalid(format!("document: {e}")))?;
|
let mut d: Document = serde_json::from_str(s).map_err(|e| DocError::Invalid(format!("document: {e}")))?;
|
||||||
|
if d.features.len() > MAX_FEATURES || d.params.len() > MAX_PARAMS {
|
||||||
|
return Err(DocError::Invalid("document too large".into()));
|
||||||
|
}
|
||||||
// Feature inputs get parameter names (designs from before they had them).
|
// Feature inputs get parameter names (designs from before they had them).
|
||||||
let mut d = d;
|
|
||||||
let ids: Vec<u64> = d.features.iter().map(|f| f.id).collect();
|
let ids: Vec<u64> = d.features.iter().map(|f| f.id).collect();
|
||||||
for id in ids {
|
for id in ids {
|
||||||
d.name_feature_inputs(id);
|
d.name_feature_inputs(id);
|
||||||
}
|
}
|
||||||
// Designs from before occurrences: every component gets one, in place.
|
// Designs from before occurrences: every component gets one, in place.
|
||||||
let mut d = d;
|
|
||||||
let missing: Vec<(u64, u64)> =
|
let missing: Vec<(u64, u64)> =
|
||||||
d.components.iter().filter(|c| !d.occurrences.iter().any(|o| o.component == c.id)).map(|c| (c.id, c.parent)).collect();
|
d.components.iter().filter(|c| !d.occurrences.iter().any(|o| o.component == c.id)).map(|c| (c.id, c.parent)).collect();
|
||||||
for (c, p) in missing {
|
for (c, p) in missing {
|
||||||
|
|||||||
Reference in new issue
Block a user