fix: don't drop image-occlusion properties after an empty/backslash value#5187
Draft
krMaynard wants to merge 1 commit into
Draft
fix: don't drop image-occlusion properties after an empty/backslash value#5187krMaynard wants to merge 1 commit into
krMaynard wants to merge 1 commit into
Conversation
…alue parse_image_cloze parsed properties with a nom escaped/separated_pair loop that broke on the first parse failure, silently discarding the failing property and every property after it. Two reachable inputs triggered this: an empty value (e.g. an empty text label, `text=`) and a value containing a backslash not followed by `:` (e.g. LaTeX like `\frac`). In both cases the remaining occlusion properties (scale, font size, position, ...) were lost. Parse by splitting the shape off the first colon, then splitting the rest on unescaped colons and each property on its first `=`, so every property is read independently and empty/backslash values are preserved.
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.
Linked issue (required)
Fixes #5186
Summary / motivation (required)
parse_image_clozeparsed properties with a nomescaped/separated_pairloop that broke on the first parse failure, silently discarding the failing property and every property after it. Two reachable inputs triggered this:text=), and:(e.g. LaTeX like\frac).In both cases the remaining occlusion properties (scale, font size, position, …) were lost.
The fix parses by splitting the shape off the first colon, then splitting the rest on unescaped colons and each property on its first
=, so every property is read independently and empty/backslash values are preserved.Steps to reproduce (required, use N/A if not applicable)
How to test (required)
Checklist (minimum)
./ninja checkor an equivalent relevant check locally.Details
Adds a unit test covering empty-value and backslash-value inputs preserving subsequent properties. The full CI workflow (
checkon Linux/macOS/Windows,format,minilints) was run against this exact commit on my fork: https://github.com/krMaynard/anki-fork/actions/runs/29983177217Before / after behavior (optional)
Before: an empty or backslash property value drops that property and all following ones. After: all properties are preserved.
Risk / compatibility / migration (optional)
Low–moderate: rewrites the occlusion property parser. Covered by unit tests; parsing output is unchanged for well-formed inputs.
UI evidence (required for visual changes; otherwise N/A)
N/A
Scope