Skip to content

Fix crash on rem lengths in text-indent and word-spacing - #283

Merged
eXpl0it3r merged 1 commit into
masterfrom
fix/rem-length-crash
Nov 10, 2026
Merged

eXpl0it3r merged 1 commit into
masterfrom
fix/rem-length-crash

Conversation

@eXpl0it3r

Copy link
Copy Markdown
Collaborator

A rem length in text-indent or word-spacing, e.g. <p style="text-indent: 2rem">, throws an InvalidOperationException while the styles are applied, and as such the whole document fails to load. Both properties convert em to pixels in their setter via NoEms, and CssLength only looks at the last two characters of the value, so 2rem ends up as an em length with a parse error, which ConvertEmToPixels then refuses. The fix skips the conversion for lengths that didn't parse, same as font-size already does.

Note that rem still resolves to 0 here, like it does for margin, padding and the other lengths. Resolving it against the root element's font size is a separate change.

How to test this PR?

CI should succeed. TextPropertyTests.RemLengthDoesNotFailTheDocument covers text-indent and word-spacing and fails on master.

@eXpl0it3r
eXpl0it3r force-pushed the fix/rem-length-crash branch from 2b3276f to c36b936 Compare November 10, 2026 19:06
@eXpl0it3r
eXpl0it3r merged commit 198032a into master Nov 10, 2026
18 checks passed
@eXpl0it3r
eXpl0it3r deleted the fix/rem-length-crash branch November 10, 2026 20:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant