Skip to content

Commit

Permalink
Escape outputs in the browser formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
meh committed Sep 9, 2013
1 parent f0b826d commit 4c37a3d
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions opal/opal/spec/browser_formatter.rb
Expand Up @@ -70,6 +70,10 @@ def html=(html)
`#{ @element }.innerHTML = html`
end

def text=(text)
self.html = text.gsub(/</, '&lt').gsub(/>/, '&gt')
end

def type=(type)
`#{ @element }.type = type`
end
Expand Down Expand Up @@ -108,7 +112,7 @@ def start

@summary_element = Node.create 'p'
@summary_element.class_name = "summary"
@summary_element.html = "Runner..."
@summary_element.text = "Runner..."

@groups_element = Node.create("ul")
@groups_element.class_name = "example_groups"
Expand All @@ -129,7 +133,7 @@ def finish
time = Time.now.to_f - @start_time
text = "\n#{example_count} examples, #{@failed_examples.size} failures (time taken: #{time})"

@summary_element.html = text
@summary_element.text = text
end

def example_group_started group
Expand All @@ -140,7 +144,7 @@ def example_group_started group

description = Node.create("span")
description.class_name = "group_description"
description.html = group.description.to_s
description.text = group.description.to_s
@group_element.append description

@example_list = Node.create "ul"
Expand Down Expand Up @@ -182,11 +186,11 @@ def example_failed example

description = Node.create "span"
description.class_name = "example_description"
description.html = example.description.to_s
description.text = example.description.to_s

exception = Node.create "pre"
exception.class_name = "exception"
exception.html = output
exception.text = output

wrapper.append description
wrapper.append exception
Expand All @@ -201,7 +205,7 @@ def example_passed example

description = Node.create "span"
description.class_name = "example_description"
description.html = example.description.to_s
description.text = example.description.to_s

wrapper.append description
@example_list.append wrapper
Expand Down

0 comments on commit 4c37a3d

Please sign in to comment.