mirror of
https://github.com/storytold/gridcraft.git
synced 2026-10-29 13:16:50 -06:00
Engine: a linked paste of values from a file carries the file's trust
A linked paste writes formulas even when it pastes values, but the values exception skipped the trust update, so a Local workbook stayed Local after linking to a FromFile one. The exception now applies only to unlinked pastes.
This commit is contained in:
@@ -1184,8 +1184,10 @@ fn paste_special(s: &mut Session, p: &Json) -> Result<Json> {
|
||||
Ok(())
|
||||
})?;
|
||||
// Formulas, formats (conditional formats hold formulas) and validation from an untrusted file
|
||||
// leave the destination untrusted; plain values, column widths and notes carry nothing active.
|
||||
if !same_doc && !matches!(what, What::Values | What::ValuesAndNumberFormats | What::ColumnWidths | What::Comments) {
|
||||
// leave the destination untrusted; plain values, column widths and notes carry nothing active
|
||||
// (a linked paste of values still writes formulas).
|
||||
let passive = matches!(what, What::ColumnWidths | What::Comments) || (!link && matches!(what, What::Values | What::ValuesAndNumberFormats));
|
||||
if !same_doc && !passive {
|
||||
let d = s.doc_mut()?;
|
||||
d.trust = d.trust.receive(clip.trust);
|
||||
}
|
||||
|
||||
@@ -336,6 +336,10 @@ fn pasting_from_a_file_carries_its_trust() {
|
||||
// Values carry nothing that runs.
|
||||
s.execute("edit.pasteSpecial", json!({"what": "values", "at": "B1"})).unwrap();
|
||||
assert_eq!(trust(&s), Trust::Local);
|
||||
// A linked paste of values still writes formulas.
|
||||
s.execute("edit.pasteSpecial", json!({"what": "values", "link": true, "at": "B2"})).unwrap();
|
||||
assert_eq!(trust(&s), Trust::FromFile);
|
||||
s.new_workbook();
|
||||
s.execute("edit.paste", json!({"at": "C1"})).unwrap();
|
||||
assert_eq!(trust(&s), Trust::FromFile);
|
||||
assert_eq!(v(&s, "C1").display(), "2");
|
||||
|
||||
Reference in New Issue
Block a user