A checked save (`write_atomic_checked`, used by the engine's file writes
while automation write roots are set) opens the destination folder once
and puts the file in place through that open folder. A folder moved
after it was opened still received the file, so moving it out of the
write root while the file was written placed the file outside the root.
After the file is written, before it takes the old file's permissions
and again right before it is renamed into place, the folder's current
path is checked again with the same check. The copy fallback checks it
before the target is opened and again before the target is created or
overwritten. A folder moved outside the root, or one whose current path
the system does not report (FreeBSD), is refused: the temporary file
and any copy of the old content are removed, and the error names the
original destination. A move within the root keeps working as before.
Follows the checked-write work in 4cb6f8f152 and 6cf9145890.
The shared gate's undeclared-read check (select legs) reports two reads
on main: crates/text/build.rs reads the workspace root (`.`) and
crates/engine/src/tests/fontfiles.rs reads `crates`. Neither path names
another member's files.
- crates/text/build.rs takes the workspace root as the second ancestor
of the crate directory instead of joining "../..". A relative
CRAFT_FONTS_DIR still resolves from the same directory.
- the_fonts_folder_next_to_a_document_is_an_absolute_path builds its
climb to the filesystem root from ParentDir components instead of
formatting a repeated "../". The test still opens the document by a
relative path to its temporary folder.
The check reports 0 problems on the result, down from 2 on main.
A path string that continues on the next line with a backslash now
decodes to the joined file name, so the conditional route is kept.
A range argument with two fixed bounds (1..4, 1..=4) no longer counts
as an input, so the round-trip census diagnostic stays; a range with a
variable bound still suppresses it. Adds a test for a bracket in a
cfg_attr path filename keeping its sibling cfg gate.
- An entry name after `::` (`defaults::c`) is a path segment, not a read of the loop binding.
- A `let` initializer scans to the end of its statement, so a block initializer binds its tail
(`{ prepare(); c }`) and not the earlier statements in the block; `if let` and `while let`
end at their block.
- A call keeps its name when masked comment whitespace sits before `(`, except after a keyword
(`if (a)`).
- The argument-guard and alias tests now depend on the logic they cover.
A plain #[path = "\x63hild.rs"] after #[cfg_attr(windows, path = "child.rs")]
loads child.rs on Linux and FreeBSD, but test-lint compared the undecoded
spelling with the file name, dropped that route and reported a test in
child.rs as never-run. The plain attribute and the path argument of
cfg_attr now decode the escapes of an ordinary string literal with the
same unescape the cfg values use. Raw string literals are read as written.
- A path written as a folder (`draft.svg/`, `draft.svg/.`) is refused
instead of saving `draft.svg`.
- The second check uses the name the file is stored under, so on a
volume that ignores letter case a grant for `Report.svg` allows a save
to `report.svg`.
- Where the rename is refused, the copy of the old content is made
beside the temporary file through the open folder, and in the system's
temporary folder only when the folder takes no new file.
- The copy of the old content is read from the file that is then
overwritten: when another file is at the name by then, nothing is
overwritten and the new content stays in the temporary file.
- On Apple platforms the folder is opened with `O_SEARCH`, so a folder
that can be written and searched but not listed takes the file.
- On Linux the replaced file's ACL is read through an `O_PATH` handle,
so a file its owner can write but not read keeps its ACL.
- The moved-folder test expects the original folder in the message on
FreeBSD, which does not report where an open folder is now.
A loop over a whole table whose body passes the entry to a call together
with other state (a command run, a file written, a render, a parse of
other input) checks behavior for each entry, so the census rule no
longer reports it. A lookup, a call on the entry alone, literal
arguments and calls in a failure message still count as a census.
The call counts only where it runs whenever the loop's assertions pass:
not after an `||`, not on the right of an `&&` whose result is not
asserted, not inside an `if`, `else`, `match` arm, `while` or async
body, and not inside a closure the loop never calls. A name counts as
the entry from the `let` that binds it from the entry to the end of its
block, and not where a nested loop, a closure parameter or another
`let` rebinds it or where it names a field. An asserting helper keeps a
loop out of the census only where it runs the same way, and a round trip
can read the entry as its receiver (`k.parse()`).
The test caught any panic from its closure, so a failed set_permissions
would also pass it while the file was still writable. It now asserts
the file is read-only before its panic and checks the caught payload is
that panic's message.
Resolve the docs/ui-parity.md conflict by taking main's tables and adding the Headless column to every Summary and behaviour table again (365 rows, all unknown); counts in the Headless section updated.
The second check of a checked write passed the open folder's path as
text and looked it up again. A path that was not valid UTF-8 was refused,
and a folder on that path replaced by a link into an allowed folder
between the two lookups could let a place outside pass.
check_write_real compares the open folder's real path with the write
roots and the script's grants as it is, without looking it up again.
- The folder is opened with O_PATH on Linux, Android and FreeBSD, so a
folder that can be written and searched but not listed takes the file.
The folder flush opens it for reading, and an error there still
reports the completed write.
- The replaced file's permissions are read after the new content is
written, as write_atomic_with reads them, so permissions taken away
meanwhile stay taken away. Its ACL is read only from the same file.
- A folder that changed while it was opened is no longer reported as a
read-only location.
- Errors name the kept temporary file where its folder is now, after
the folder moved.
- A file already at the name the old content is copied to is left as it
is: only a copy this save made and could not finish is removed.
Realm::define_host_classes registered each class, and defined its global
constructor, before it checked the next one. A batch whose second class
named an unknown parent or a member twice failed with the first class
already installed, so a retry failed with "defined twice". A failed
instance did the same, and could leave an object scripts held with a
class the realm no longer had.
Every class's name, parent and members are now checked before any class
is added, so a child must still follow its parent in the batch. A
failure after that point removes the classes added, puts back each
global the call replaced and the class of each object an instance moved
to a new class. The replaced globals stay rooted until the call ends, so
a collection during the call does not free them.
a_script_gate_does_not_write_over_a_read_only_file created its
ReadOnlyFixture guard after two assertions, so a failure in either left
the test folder behind. The guard is now created right after the file
path is made, before the file is written.