Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/inscriptis/model/css.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
)
from inscriptis.model.html_element import HtmlElement

# upper limit for lenght specifications to prevent
# unbound memory allocation by malformed HTML.
MAX_EM_LEN = 100000


class CssParse:
"""Parse CSS specifications and applies them to HtmlElements.
Expand Down Expand Up @@ -68,8 +72,8 @@ def _get_em(length: str) -> int:
unit = _m.group(2)

if unit not in ("em", "qem", "rem"):
return round(value / 8)
return round(value)
value = value / 8
return min(round(value), MAX_EM_LEN)

# ------------------------------------------------------------------------
# css styles
Expand Down
Loading