Commit 7826abb9adc2531bf33c5c25f2c713e543aa8b5f
1 parent
170a723e
Exists in
theme-brasil-digital-from-staging
and in
9 other branches
virtuoso: strip tags from rdf content
Showing
2 changed files
with
12 additions
and
1 deletions
Show diff stats
plugins/virtuoso/lib/ext/literal.rb
plugins/virtuoso/test/unit/triples_template_test.rb
| ... | ... | @@ -38,4 +38,13 @@ class TriplesTemplateTest < ActiveSupport::TestCase |
| 38 | 38 | assert_match /<p style="color:red">World<\/p>/, content |
| 39 | 39 | end |
| 40 | 40 | |
| 41 | + should 'do not allow js injection' do | |
| 42 | + article.stubs(:plugin).returns(mock) | |
| 43 | + article.plugin.expects(:virtuoso_client).at_least_once.returns(mock) | |
| 44 | + article.plugin.virtuoso_client.expects(:query).returns([{'var' => RDF::Literal.new('<script>alert("hello");</script>')}]) | |
| 45 | + article.template = "{% for row in results %}{{row.var}}{% endfor %}" | |
| 46 | + | |
| 47 | + assert_no_match /<script>/, article.template_content | |
| 48 | + end | |
| 49 | + | |
| 41 | 50 | end | ... | ... |