fix(task-16): custom properties refuse pre-R2004 headlessly, line breaks, and AutoCAD's invalid keys before any write
Three header-only-write / half-write classes in drawing_properties_set:
1. Measured: ezdxf emits $CUSTOMPROPERTYTAG / $CUSTOMPROPERTY only after
$LASTSAVEDBY, which does not exist before R2004, so on an R12 (AC1009) or
R2000 (AC1015) document the write reported ok, drawing_properties_get
echoed it from memory, and drawing_save_as (version kept) wrote nothing --
the class f3ff703 removed for CANNOSCALE. The headless engine now refuses
with a ValueError naming the DXF version and "save as R2004 or newer",
before custom_vars is touched; the dwgprops capability reason no longer
claims custom_properties_supported unconditionally.
2. A line break in a custom key or value passed validation, ezdxf wrote it
unescaped, and the saved DXF failed to reopen (DXFStructureError) -- the
whole drawing lost, reported as success. Refused by name in the shared
validator.
3. Measured on AutoCAD 2026: AddCustomInfo rejects keys with leading/trailing
whitespace and keys containing '=', ';' or a no-break space as 'Invalid
key' -- mid-write, after the summary and earlier keys were applied, as an
unnamed COM error -- while the headless engine wrote them. The shared
validator now mirrors those rules, so both engines refuse before writing
(internal spaces, tabs, unicode and 300-char keys stay accepted, as
AutoCAD accepts them).
Pinned by save+reopen tests on R12/R2000 (refused, file reads back empty),
R2004 (round-trips), the newline case (refused, the file still opens), and
the fake-SummaryInfo COM test (no ActiveX call reaches SummaryInfo).
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FKFStjEFzpGyLq5bMpWxTd
This commit is contained in:
co-authored by
Claude Opus 5
parent
10a7372ce7
commit
2b9791fbcd
@@ -6962,8 +6962,14 @@ async def drawing_properties_set(
|
||||
engine (`capability: dwgprops` — SummaryInfo lives in the DWG, a DXF has
|
||||
no slot for it; custom properties still work headlessly), a non-string
|
||||
value (`TypeError` naming the field or key — nothing is coerced with
|
||||
`str()`), an empty custom key. On the live engine a custom key is added
|
||||
with AddCustomInfo when new and changed with SetCustomByKey when present.
|
||||
`str()`), an empty custom key, a custom key AutoCAD's AddCustomInfo would
|
||||
reject mid-write (leading/trailing whitespace, `=`, `;`, no-break space —
|
||||
`ValueError` naming the key, on both engines), a line break in a custom
|
||||
key or value (it corrupts the DXF on save), and headlessly a document
|
||||
older than R2004 (`ValueError` — ezdxf only writes the custom-property
|
||||
header pairs for AC1018+, so they would vanish at save; save as R2004 or
|
||||
newer first). On the live engine a custom key is added with AddCustomInfo
|
||||
when new and changed with SetCustomByKey when present.
|
||||
"""
|
||||
summary = {
|
||||
"title": title,
|
||||
|
||||
Reference in New Issue
Block a user