Repository navigation
Make text property XML reader and writer agree - #410
Open
johnml1135 wants to merge 6 commits into
Open
johnml1135 wants to merge 6 commits into
johnml1135 wants to merge 6 commits into
Conversation
TsPropsSerializer (StyleRules) and TsStringSerializer (runs) wrote properties and values their own reader rejects, so the record failed to load as "corrupted record"; others were written but dropped. Reader: accept MarginTop, directionDepth, hyphenate, maxLines, cellBorderWidth, cellSpacing, cellPadding, setRowDefaults, relLineHeight, negative numbers (incl. offset on a run), numeric enumeration and unit values, and prop_N in BulNumFontInfo; ignore tabDef, tabList, charStyle, paraStyle and editable quietly. Writer: write marginTop and the custom bullet (bulCusTxt, previously lost on save); stop writing tabDef, tabList, charStyle, paraStyle and editable, which were never read back; never throw on a value it holds (lineHeight int.MinValue, bullet font info with font features, malformed bullet/ws-style/object data/tags, XML-invalid characters); write numbers with the invariant culture. Add TextPropsRoundTripTests: every FwTextPropType constant must be classified, and round-trips through both serializers; any value the writer emits must load. Fixes sillsdev#409 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Write a relative line height unsigned again, as master did, so older readers never meet a new negative (P3-1). - Strip unpaired surrogates before ICU normalization and in the invalid-XML regex, through one helper shared with run text (P3-2). - Skip prop_N above 0xFFFF in BulNumFontInfo instead of renumbering it (P3-3); reject negative numeric units (P3-4). - Debug.WriteLine wherever the writer drops or strips a malformed value (P3-5); fix an indentation slip (P3-6). - Tests: escape U+FFFF literals, add lone surrogates and ws/baseWs to the sweep, take NotPersisted kinds from the table (P3-7, P3-8). - Split the CHANGELOG entry into Fixed and Changed (P3-9). - AGENTS.md: note DisableGitVersionTask for detached-HEAD builds. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 5, 2026
Open
The writer itself writes type="picture" for picture object data, and the reader ignores it. The Debug.Assert in both readers fired on that writer output, which in a Debug build opens a dialog on net462 and hangs the test host (AnyStrValue_Loads(6)). Use Trace.TraceWarning. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
GetXmlSafeString now removes unpaired surrogates and invalid XML characters itself instead of delegating to TsStringSerializer's GetXmlSafeText. Run text must keep its length (offsets index into it), so its handling may change to replacement; property values are not indexed and can simply drop what XML cannot hold. Keeping the two helpers separate lets each evolve without changing the other. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
johnml1135
added a commit
to johnml1135/liblcm
that referenced
this pull request
Nov 5, 2026
…r custom String fields - GetXmlSafeText replaces lone surrogates first, so it keeps the length whether or not StripInvalidXmlChars also removes lone surrogates (as sillsdev#410's regex does), and removing a control character cannot join a lone high and low surrogate into a false pair. Test pins the order. - CmObject.SetCustomPropertyForSDA runs NormalizeNfd on custom String fields, like model String properties. Test added. - Tests use \u escapes for every non-ASCII character. - CHANGELOG: say that callers relying on the exception now get U+FFFD. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
liblcm stores an empty string property as null. The new GetXmlSafeString dereferenced it, so saving such a property threw, and the custom bullet (now written) added more ways to reach it. Guard null and empty there, and in the ktptTags writer. A Field name that is only characters XML cannot hold is now treated as no name instead of writing an empty one that does not load. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…g comment Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #409
A custom bullet chosen in Format > Styles > Bullets (LT-16341) was lost every time the project was reopened. It is now saved; it now also reaches the CSS and Word exports.
The rest stops
TsPropsSerializer(StyleRules) andTsStringSerializer(runs) writing XML their own reader rejects, which shows as "corrupted record" and closes FieldWorks.Compatibility. An independent sweep wrote every property × variation × value with this branch and read it back with master's reader. The only new rejection was a negative relative line height, and that is now written unsigned, as master did. No FLEx workflow persists the eight Views layout attributes (set only at display time); I recommend keeping them written, which matches master byte-for-byte.
Tests.
TextPropsRoundTripTestsmakes everyFwTextPropTypeconstant classified. Each one round-trips through both serializers, and any value the writer emits must load. 19*_Failtests that pinned rejection of-1are now*_Negative. Green on net462 and net8.0.Reader: newly accepted
MarginTop, plus directionDepth, hyphenate, maxLines, cellBorderWidth, cellSpacing, cellPadding, setRowDefaults and relLineHeightprop_Nin BulNumFontInfo (N ≤ 0xFFFF)Debug.FailWriter changes
marginTop;bulCusTxtint.MinValueand bullet font info with font name and features, which used to throwDebug.WriteLine) instead of throwing🤖 Generated with Claude Code
This change is