ankitects / ankitects/anki

Image occlusion: an empty or backslash property value drops that and all subsequent properties

Open
#5,186 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
30.5k
Forks
3.2k
Avg merge
2d 8h
Merged PRs (30d)
72

Description

### Description

`parse_image_cloze` in `rslib/src/image_occlusion/imageocclusion.rs` parses occlusion properties in a loop that stops at the first property it fails to parse, silently discarding that property **and every property after it**. Two reachable inputs trigger this:

- a property with an empty value (e.g. an empty text label, `text=`)
- a value containing a backslash not followed by `:` (e.g. LaTeX such as `\frac`)

In both cases the remaining occlusion properties (scale, font size, position, …) are lost.

### Steps to reproduce

1. Create an image-occlusion note whose occlusion data contains a property with an empty value (e.g. an empty text label) or a backslash value (e.g. LaTeX like `\frac`).
2. Round-trip / re-parse the occlusion.
3. Properties after the offending one (scale, font size, position) are dropped.

### Expected

All properties are preserved regardless of empty or backslash-containing values.

A PR follows.

Contributor guide

Open the contributing guide

Research direction

Start in rslib/src/image_occlusion/imageocclusion.rs at parse_image_cloze and reproduce the round-trip with an empty text= value and a LaTeX value such as \frac. Trace how parsing handles the offending property and verify that scale, font size, position, and all other subsequent occlusion properties are preserved.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.