predefined_quit reports menu::PredefinedMenuItem::quit after use muda as menu;, use muda::{self as menu}; or extern crate muda as menu;, and reads those names in the scope of each path and import. A leading :: names an external crate, an extern crate of another crate shadows the name, and use muda as menu; binds menu to the crate only where muda names it.
The test opens the FIFO for reading and writing and puts the signature
in the pipe before the scan. A scan that opened the FIFO would read the
signature and leave out `kept.rs` instead of blocking, so the test no
longer waits on a thread with a 30-second bound.
- A native-only `if`, `while`, `match` or `for` whose condition holds a
block expression (`if { ready } { ... }`, `while !{ x }`, `unsafe`,
`loop`, `async` and labeled blocks) is covered up to its real body, so
`std_instant` skips the body.
- `predefined_quit` no longer follows `use muda::PredefinedMenuItem as
Item;` or `type Alias = muda::PredefinedMenuItem;` when the braces
around it bind `muda` to something else (`use other_menu as muda;`).
`::muda::` still names the crate.
- In `std_instant`, a `use` or `mod` that binds an alias name to
something else and carries its own `cfg` attribute that may be false
on `wasm32-unknown-unknown` no longer hides an outer
`use std::time as clock;`.
- A `use` whose path is longer than the copy limits still binds its name,
and keeps its first segment, so another crate's long path no longer reads
as an unbound `PredefinedMenuItem` and a long `crate::` path still reads as
a possible re-export.
- `std_instant` reports `use std::{time::Instant as _};`; `_` only stops the
name from being bound.
- `std_instant` checks the leaves read without aliases as well as the ones
read through them, so an alias in a nested module no longer hides an outer
`use std::{time::Instant};`.
- A cycle of `mod` declarations that no other file names keeps a crate
root: its `lib.rs` or `main.rs`, or every member when it has neither. A
`lib.rs` that names itself through a disabled `#[path]` declaration is
checked again.
- `predefined_quit` does not report `muda::PredefinedMenuItem::quit` where
a `use` or a `mod` in scope binds `muda` to something else
(`use other_menu as muda;`); `::muda::` is still reported.
std_instant ended a native-only fn, impl, trait, struct, enum or union item
at the closing brace of a block inside its angle brackets, such as the
const generic default in `struct Native<const N: usize = { 1 + 2 }>`, a
`Foo<{ N }>` argument, a return type or a `where` clause. The rest of the
item was then checked as web code. Blocks inside those angle brackets no
longer end the item, and the `>` of `->` does not close a bracket.
rust_sources opened a folder's CACHEDIR.TAG without checking its file
type, so it followed a symbolic link and could block on a FIFO. It now
reads the marker only when symlink_metadata reports a regular file;
any other marker is not read and the folder is listed.
predefined_quit reported a bare `PredefinedMenuItem::quit` when the file
imported another crate's type under that name or defined its own, and
applied a rename of muda's type (`use muda::PredefinedMenuItem as Item`)
to the whole file. A name used on its own is now read in the innermost
braces around it, within its module, that bind it: it is reported when
they import or alias muda's type, and not when they only bind another
type. An import or alias through `crate::`, `self::` or `super::`, a
binding inside an item with a `cfg` attribute and an associated type in
an `impl` or `trait` do not bind the name.
std_instant applied an alias of `std::time` (`use std::time as clock`)
to the whole file. A path or `use` through the alias is now reported
only where the alias is in scope by the same rule, so another module's
`use web_time as clock` is not read as `std::time`.
A use path whose first segment is longer than 32 bytes was dropped by the
use-path copying limit. With `use std::time as <long name>;`, std_instant
missed `use <long name>::{Instant as Clock};` and `use <long name>::*;`.
std_instant now reads the use declarations a second time with the names
bound to std::time, and a path that starts with one of them is read as a
path that starts with std::time. The alias is not copied into the leaves,
so the limits still bound every other path.
The `>` of `->` and `=>` was read as the end of a path, so both guards
skipped an absolute path after it: `fn now() -> ::std::time::Instant` and
`_ => ::muda::PredefinedMenuItem::quit(None)`. Those paths are now checked.
- A native-only `if`, `while`, `match` or `for` now ends at its body's
closing brace, or at the last block of an `else` chain. A `{` in the
pattern of a `let` (also after `&&` in a chain) or a `for` opens a
struct pattern, so `#[cfg(unix)] if let State::Ready { .. } = s { .. }`
no longer ends at the pattern's brace and leaves its body checked.
- A raw identifier spelled like a keyword (`r#let`, `r#in`, `r#match`)
is read as a name. `mod r#match;` still names `match.rs`.
- predefined_quit reports a qualified path only as
`muda::PredefinedMenuItem` (or `::muda::...`), so
`other_crate::PredefinedMenuItem::quit` is not reported. The plain
name and a `use muda::PredefinedMenuItem as X` rename still are.
A native-only item ends at its closing brace or `;`, so an item after it
on the same line is checked, and a second native-only item there stays
exempt. The tests cover `fn`, `impl`, `mod`, braced and tuple `struct`
items, and a `use` with a native cfg after another gated item.
- A cfg predicate nested more than 64 levels deep is unknown, so its
item is checked instead of skipped.
- cfg(true) and cfg(false) are read as their values; r#true and
r#false stay option names.
- String values in cfg predicates have their escapes decoded; a string
with an invalid escape is unknown.
- The `:` after a field's name starts its type, so a native-only
`callback: fn(),` field ends at its comma and later fields are checked.
- use<...> is read as a capturing bound, not a declaration, and the
guards keep use paths of at most eight segments of at most 32 bytes,
so a long prefix or name shared by many leaves is not copied into each.
- std_instant finds the modules of a file that a #[path] attribute names
next to that file, separately from a plain load of the same file.
- predefined_quit reports <muda::PredefinedMenuItem>::quit.
- wgsl_float_literals ends line comments and counts lines at every WGSL
line break, and skips digits inside Unicode identifiers.
A native-only `let`, `return` or other statement whose value holds an
`if` or `match` block is now exempt up to its `;`, instead of only to the
nested block's closing brace. A match arm whose value holds a block runs
to its comma. Const blocks and labeled blocks at the head of a statement
or arm end at their closing brace, so the next statement is checked.
A `use` split over lines is reported once, on the line where its path
starts.
Adds tests for paths split by line breaks and comments (CRLF included),
cfg attributes with code before and after them on one line, other time
modules and longer names, literals and labels, and a large source.
New tests cover cases the guards already handle:
- wgsl_float_literals checks a literal that follows a hex literal and an
operator (0x1.0p0+1e39, 0xFF+1e39, 0x1f-4e38).
- std_instant reports Instant in a use group split over several lines.
- '{' and '}' character literals do not end a native cfg item early.
- An escaped line break in a string keeps the line numbers after it.
- Use groups and cfg predicates nested 100,000 deep return without
exhausting the stack.
- rust_sources skips a broken symbolic link to a file or a folder.
item_end now ends a cfg-gated statement that starts with a bare block at the block's closing brace, so code after it is checked. When a `.` or `?` follows the closing brace of a block item, the item runs on to its `;` or `,`, so a method call after a cfg-gated block or `unsafe` block stays covered by the cfg.
README item 2, the wgsl_float_literals rustdoc and the boundary test comment now say the
scanner compares each literal's value rounded to f64, so a literal that exceeds the maximum
by less than f64 precision, such as 0x1.fffffe000000001p+127f, is not reported. They also say
0x1.fffffep+127f equals f32::MAX and 3.4028234663852886e38 rounds to it.
rust_sources skips a folder only when its CACHEDIR.TAG starts with the line
Signature: 8a477f597d28d172789f06886806bc55. The doc comment and the crate
README now say so instead of naming any CACHEDIR.TAG file.
std_instant read each file on its own, so `#[cfg(not(target_arch =
"wasm32"))] mod native;` in lib.rs did not stop it from reporting
std::time::Instant in native.rs when both came from one rust_sources
call.
std_instant now first collects every `mod name;` declaration and treats
the file it names as native-only when the declaration is inside an item
whose cfg is false on wasm32-unknown-unknown, along with the files that
file declares. A file that a declaration outside such items also reaches
from a crate root is still checked. Module files are found by rustc's
rules: next to lib.rs, main.rs and mod.rs, in the stem folder of any
other file, below enclosing inline modules, and through #[path] on the
declaration or on an enclosing inline module. Declarations inside more
than 64 inline modules are not followed, so their files are checked.
predefined_quit and std_instant now run on a small Rust lexer instead of
a masked line search:
- Character and byte literals such as '"' no longer open a phantom
string that hides the code after them.
- A Quit call split by tabs or a line break around :: is reported, a
different name such as MyPredefinedMenuItem or quitter is not, and a
use muda::PredefinedMenuItem as X rename is followed.
- std_instant reports std::time::Instant, <m>::Instant where a use binds
m to std::time, and each use that imports std::time::Instant or
std::time::*. A line that also names web_time is still reported, and
an unrelated time::Instant is not.
- cfg attributes are read from code, not from strings or comments, and
evaluated for wasm32-unknown-unknown (all, any, not, unix, windows,
target_* keys). An outer attribute covers the item after it, an inner
one the rest of its module. A predicate that depends on a feature or
test is checked.
wgsl_float_literals skips integer literals, reports hexadecimal floats
above f32::MAX, and checks an h-suffixed float against 65504.
rust_sources does not follow symbolic links, skips folders that hold a
CACHEDIR.TAG file, no longer drops every file when the root itself is
under a folder named tests, and returns an error for a file over 8 MiB,
more than 256 MiB in all or more than 50,000 files.
rust_sources_with_limits takes other limits.
The tests use a scratch folder that is never reused and is removed when
a test panics. The crate is not published, and the root README lists
it.
Add craft-testkit with source guards for platform rules that broke before:
- predefined_quit: flags calls of muda PredefinedMenuItem::quit that bypass dirty document save prompts and window teardown on macOS.
- wgsl_float_literals: scans WGSL shaders using PhotoCraft's decimal float scanner and flags literals exceeding f32 finite range that fail on WebGPU compilers (Tint).
- std_instant: flags lines naming std::time::Instant without web_time in code running on the web, preventing wasm32 runtime panics.
- rust_sources: directory crawler discovering a crate's .rs sources while excluding test files and test directories.
The PKCS#12 MAC and the PDF security handler's /U, R5/R6 and file-key
checks used plain equality, which stops at the first differing byte and
narrows a guess. Both crates now use a length-checked comparison that
folds every byte (the helper craft-offcrypto already used).
An archive could hold many individually allowed members whose combined
decompression was unbounded, because both readers passed
max_total_bytes: u64::MAX to craft-zip. Each now passes MAX_TOTAL (4 GiB)
and every entry read is charged to it.
craft-fig's declared-entry cap drops from 1,000,000 to 100,000 to match the
other ZIP readers; its images were already bounded by Limits::max_image_total.
The review of wordcraft#6345 found that text in code page 932, 936, 949 or 950
was read a byte at a time, each byte above ASCII becoming U+FFFD, and the file
opened with its characters gone. Such a file is refused as every Word 6.0/95
file was before, until the piece walk decodes byte pairs. The test that
asserted the replacement characters is replaced by one that asserts the
refusal and that the same text in a Western font still opens.
The module comment on the Word 6 stylesheet header now matches the reader (a
u16 header size, then the header), as the other review comment asked.
(cherry picked from commit 92f8dd24d1)
Ported from storytold/wordcraft#6317, #6335 and #6345 (one series): Word 6.0
and Word 95 files are read instead of refused: text in its code page (by font
charset, language and style), character and paragraph formatting, tables and
paragraph styles. Paths follow craft-doc-binary (craft-wordmodel,
craft-codepage, craft-cfb).
(cherry picked from commit aa220afc77)
The bridge fell back to decoding in the calling process whenever no worker
was configured, or the worker failed to start, which is exactly the case the
audit called out: acadrust allocates from sizes a hostile file declares, and
an allocation failure or stack overflow ends the process. Conversions are
now refused without a worker, a worker that cannot start is an error, and
allow_in_process() is the explicit opt-in for input known to be trusted.
The create() API exposed RC4-40 and RC4-128 behind a doc comment, so an app
could write files whose encryption protects nothing. create() now returns
Unsupported for both schemes; create_legacy() and
Document::set_encryption_legacy() are the explicit ways to write a file that
must stay readable by an old reader. Tests and the encrypt example, which
read and write every algorithm, use the legacy entry points.