Skip to content

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

Open
eXpl0it3r wants to merge 1 commit into
masterfrom
fix/rem-length-crash
Open

eXpl0it3r wants to merge 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant