Skip to content

Commit 443de05

Browse files
committed
correctly escape JSON in the iframe template
1 parent 555c711 commit 443de05

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

Diff for: test/server.rb

+6-1
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,13 @@ def script_tag src
4242
content_type 'application/json'
4343
data.to_json
4444
elsif params[:iframe]
45+
payload = data.to_json.gsub('<', '&lt;').gsub('>', '&gt;')
4546
<<-HTML
46-
<script>window.top.jQuery.event.trigger('iframe:loaded', #{data.to_json})</script>
47+
<script>
48+
if (window.top && window.top !== window)
49+
window.top.jQuery.event.trigger('iframe:loaded', #{payload})
50+
</script>
51+
<p>You shouldn't be seeing this. <a href="#{request.env['HTTP_REFERER']}">Go back</a></p>
4752
HTML
4853
else
4954
content_type 'text/plain'

0 commit comments

Comments
 (0)