Skip to content
This repository has been archived by the owner on Oct 9, 2023. It is now read-only.

Escape / and > also so apps cannot be broken by browsers trying to 'correct' the HTML #22

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/hypernova/blank_renderer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def data
end

def encode
JSON.generate(data).gsub(/&/, '&').gsub(/>/, '>')
JSON.generate(data).gsub(/&/, '&amp;').gsub(/>/, '&gt;').gsub(/</, '&lt;').gsub(/\//, '&#47;')
end

def key
Expand Down
2 changes: 1 addition & 1 deletion spec/blank_renderer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
}
}).send(:encode)

expect(str).to match(/<\/script&gt;/)
expect(str).to match(/&lt;&#47;script&gt;/)
expect(str).to match(/&amp;gt;/)
expect(str).to match(/&amp;amp;/)
end
Expand Down