html - Looking for a popular templating language that needs XSS protection -


i'd experiment popular html templating language see if can solve xss problems in it. popular, open-source, templating language try tackle.

by templating language, mean language used generate output language combining static content in output language dynamic data source. e.g. php commonly used templating language html/css/js, , xslt templating language xml.

the ideal template language be

  1. widely used
  2. open source
  3. not have solved xss
  4. the simpler syntax better

the idea to

  1. parse each template end tree of chunks of raw html, expressions produce dynamic values need encoded, , conditional (switch/if) , loop constructs.
  2. walk tree inferring context. possible contexts might include (html_pcdata, in_js_dbl_quoted_str, etc.) if see chunk of raw html, <a href=" in html pcdata context, move context expecting part of url. when reach branch or loop, follow each branch independently, , join contexts afterwards.
  3. if language has templates, try determine static call graph can clone templates , rewrite calls given template called in multiple contexts.
  4. wrap expressions produce dynamic values calls library implement includes functions expecthtml(...), expectjsvalue(...) encode dynamic value appropriately. e.g. expecthtml(...) converts < &lt;.
  5. provide convenience functions code provies data templates can use rtti specify language of dynamic values avoid overescaping. expecthtml(...) not escape value of type html since assumed come safe source knownsafehtml(...) or stripbadtags(...)

the upcoming symfony broken down in components. releasing them 1 one. symfony templating 1 of them , candidate test.


Comments

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -