fix(anatomy): V1-2.2 owner arbitrations on SVG references and bytes
Refuse local references to ids a drawing does not define, scope canvas ids per view, upload every drawing in one stored form checked by the verdict and the preview, keep strict numeric rgb() colours, and commit real Inkscape 1.4.3 exports with their generator.
This commit is contained in:
1 parent
17d919971e
commit
e823655f09
31 files changed
+1362
-110
No files matched your search
@@ -8,6 +8,7 @@ use serde::Deserialize;
|
||||
use url::{Host, Url};
|
||||
|
||||
use crate::anatomy::svg::read_svg;
|
||||
use crate::anatomy::svg::serialize::stored_form;
|
||||
use crate::curation::ids::sha256_hex;
|
||||
|
||||
/// The private Storage bucket of the sheet drawings (`20261009100000_sheet_asset_storage`).
|
||||
@@ -155,7 +156,8 @@ pub fn parse_manifest(text: &str) -> Result<Vec<AssetEntry>, UploadError> {
|
||||
}
|
||||
|
||||
/// The bytes on disk are what the manifest recorded, and a drawing the product accepts: the
|
||||
/// core's one SVG reader keeps every element (nothing removed), as a load of the sheet would.
|
||||
/// core's one SVG reader keeps every element (nothing removed), as a load of the sheet would,
|
||||
/// and the bytes are in the stored form the verdict requires (`serialize::stored_form`).
|
||||
pub fn verify_asset(entry: &AssetEntry, bytes: &[u8]) -> Result<(), UploadError> {
|
||||
let bad = |what: &str| refuse(UploadKind::Content, format!("{}: {what}", entry.file));
|
||||
if bytes.len() != entry.byte_size || sha256_hex(bytes) != entry.sha256 {
|
||||
@@ -163,7 +165,8 @@ pub fn verify_asset(entry: &AssetEntry, bytes: &[u8]) -> Result<(), UploadError>
|
||||
}
|
||||
let text = std::str::from_utf8(bytes).map_err(|_| bad("not UTF-8 text"))?;
|
||||
match read_svg(text) {
|
||||
Ok(read) if read.removed.is_empty() => Ok(()),
|
||||
Ok(read) if read.removed.is_empty() && stored_form(&read.root) == text => Ok(()),
|
||||
Ok(read) if read.removed.is_empty() => Err(bad("not in the stored form")),
|
||||
Ok(_) => Err(bad("the SVG reader would remove content")),
|
||||
Err(error) => Err(bad(&format!("refused by the SVG reader: {error:?}"))),
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user