Merge branch '14519-wb-textile-issues'
authorLucas Di Pentima <ldipentima@veritasgenetics.com>
Mon, 26 Nov 2018 19:43:29 +0000 (16:43 -0300)
committerLucas Di Pentima <ldipentima@veritasgenetics.com>
Mon, 26 Nov 2018 19:43:29 +0000 (16:43 -0300)
Closes #14519

Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <ldipentima@veritasgenetics.com>

apps/workbench/app/helpers/application_helper.rb
apps/workbench/test/controllers/projects_controller_test.rb

index 2b48d74b20c09d407edb11d36bdb06d7152bdaa8..c4a801d68b0a645fe7c10de9cdee91f642ed4ab7 100644 (file)
@@ -16,7 +16,8 @@ module ApplicationHelper
   end
 
   def render_markup(markup)
-    sanitize(raw(RedCloth.new(markup.to_s).to_html(:refs_arvados, :textile))) if markup
+    allowed_tags = Rails::Html::Sanitizer.white_list_sanitizer.allowed_tags + %w(table tbody th tr td col colgroup caption thead tfoot)
+    sanitize(raw(RedCloth.new(markup.to_s).to_html(:refs_arvados, :textile)), tags: allowed_tags) if markup
   end
 
   def human_readable_bytes_html(n)
index 3522745fe4cc0bca3da001e12c805fe516640482..21b3361c1612d8df920217b0a43775b9f372a9de 100644 (file)
@@ -351,6 +351,24 @@ class ProjectsControllerTest < ActionController::TestCase
     assert_includes @response.body, 'Textile description with unsafe script tag alert("Hello there").'
   end
 
+  # Tests #14519
+  test "textile table on description renders as table html markup" do
+    use_token :active
+    project = api_fixture('groups')['aproject']
+    textile_table = <<EOT
+table(table table-striped table-condensed).
+|_. First Header |_. Second Header |
+|Content Cell |Content Cell |
+|Content Cell |Content Cell |
+EOT
+    found = Group.find(project['uuid'])
+    found.description = textile_table
+    found.save!
+    get(:show, {id: project['uuid']}, session_for(:active))
+    assert_includes @response.body, '<th>First Header'
+    assert_includes @response.body, '<td>Content Cell'
+  end
+
   test "find a project and edit description to textile description with link to object" do
     project = api_fixture('groups')['aproject']
     use_token :active