mirror of
https://github.com/storytold/deckcraft.git
synced 2026-10-27 12:07:02 -06:00
Fix up #247: route main's other file access through the checked io layer
design.browseTheme reads its path with io::read_file, and File › Info sizes the file with io::file_len (which checks the read root), so commands_do_not_touch_the_file_system_themselves passes. spell.rs is allow-listed beside recovery.rs: it touches only the app's own dictionary folders. main's render_slide MCP tool refuses a `path` argument (#371), so the root tests render to a file through call_app ui.render instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
9fc910886c
commit
0dfc9ccf6f
@@ -152,7 +152,7 @@ fn browse_theme(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
{
|
||||
let path = str_param(p, "path").ok_or_else(|| bad("design.browseTheme", "give `path` or `data`"))?;
|
||||
std::fs::read(path).map_err(|e| crate::EngineError::Other(format!("{path}: {e}")))?
|
||||
crate::io::read_file(path).map_err(crate::EngineError::Other)?
|
||||
}
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
return Err(bad("design.browseTheme", "give `data`"));
|
||||
|
||||
@@ -476,7 +476,7 @@ fn info(s: &mut Session, _p: &Value) -> Result<Value> {
|
||||
let st = s.doc()?;
|
||||
let doc = &st.doc;
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
let bytes = st.path.as_ref().and_then(|p| std::fs::metadata(p).ok()).map(|m| m.len());
|
||||
let bytes = st.path.as_deref().and_then(crate::io::file_len);
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
let bytes: Option<u64> = None;
|
||||
Ok(json!({
|
||||
|
||||
Reference in New Issue
Block a user