mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-10-24 09:46:59 -06:00
Many tools note things on SVG objects in attributes of their own XML namespace: a plotter's pen, a cutter's passes, a game engine's collision flag. Import dropped them, so a file that went through VectorCraft lost what other software had set on its objects. #522 asked for unknown and data-* attributes to survive a round trip; #580 kept the data-* ones, and this keeps the ones in other applications' namespaces. - Import keeps every attribute in a namespace that isn't SVG's, XLink's, XML's, Inkscape's, Sodipodi's or VectorCraft's own, on the object or layer it belongs to, in order, with its namespace URI and the prefix the file gave it (ObjectAttributes::foreign, beside the data-* attributes and the event handlers). The file is untrusted: at most 64 per object and 64 KiB per value, and what is left out is warned about. Files that declare no other namespace skip the scan. - They are the object's own, as its data-* attributes are: a pasted copy and a duplicate keep them, and deleting the object takes them with it. The native file keeps them in the object's attributes, a key written only when an object has some. - Export writes them back on the same elements and declares each namespace once, on the root, under the file's prefix. A prefix the export uses itself, or that another namespace already has, becomes prefix2, prefix3...; one XML keeps for itself (xml...) becomes ns. A name or value XML can't hold is left out with a warning. Nothing in VectorCraft reads them, and nothing in the UI lists them. svg/tests/foreign_attributes.rs: a layer's and a shape's attributes survive import, export and import again, Inkscape's and Sodipodi's own aside and with no warnings, and the native form round-trips; prefixes are made unique, and bad names and values are left out with a warning; the caps hold and are warned about once. engine tests_attributes.rs: a pasted copy and a duplicate keep them, a deleted object leaves none behind, and the native file and SVG export keep them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HhvnnnD5fTFupK8WWq35un