Skip to content

Commit

Permalink
Add explicit constraints on allowable inline styles for rich text.
Browse files Browse the repository at this point in the history
  • Loading branch information
tshead2 committed Sep 7, 2016
1 parent 0251ad3 commit ab4a7cc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion toyplot/html.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ def _draw_text(

def cascade_styles(node, font_size):
dy = node.get("dy", 0)
style = toyplot.style.parse(node.get("style", ""))
style = toyplot.require.style(toyplot.style.parse(node.get("style", "")), allowed=toyplot.require.style.rich_text)
if "font-size" in style:
font_size = toyplot.units.convert(style.pop("font-size"), target="px", default="px", reference=font_size)

Expand Down
10 changes: 10 additions & 0 deletions toyplot/require.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,16 @@ def style(value, allowed):
"-toyplot-anchor-shift",
])

style.rich_text = set([
"fill",
"fill-opacity",
"font-size",
"font-weight",
"opacity",
"stroke",
"stroke-opacity",
"stroke-width",
])

def instance(value, types):
"""Verify the type of a value."""
Expand Down

0 comments on commit ab4a7cc

Please sign in to comment.