Skip to content

Latest commit

 

History

History
37 lines (28 loc) · 987 Bytes

README.md

File metadata and controls

37 lines (28 loc) · 987 Bytes

da_css.cr

The idea is to let users use a subset of CSS to upload their own CSS files while preventing CSS security vulnerabilities.

Security links:

Example:

Let's have a String filled with this content:

blocks = DA_CSS.parse(%[ div { border: 1px solid red; } ])

blocks.each { |blok|
  blok.selectors # Deque(DA_CSS::Selectors
  blok.propertys # Deque(Color_Keyword | Color | A_String | A_Number | ...)

  width = blok.propertys.first.values.first
  case width
  when DA_CSS::Number_Unit
    width.a_number.to_number == 1
    width.unit.token.to_s == "px"
  end
}