Skip to content
This repository was archived by the owner on Jan 5, 2021. It is now read-only.

Commit 65ff266

Browse files
committed
Remove unnecessary json escape from test server and data-method test
1 parent 384fac1 commit 65ff266

File tree

2 files changed

+4
-12
lines changed

2 files changed

+4
-12
lines changed

test/public/test/data-method.js

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,6 @@ asyncTest('link with "data-method" set to "delete"', 3, function() {
2929
});
3030
});
3131

32-
var escapeMap = {
33-
'<': '&lt;',
34-
'>': '&gt;'
35-
};
36-
function escapeReplacer (entity) { return escapeMap[entity] || entity; }
37-
function escapeHTML(str) { return String(str).replace(/<|>/g, escapeReplacer); }
38-
3932
asyncTest('link with "data-method" set to "post" and "data-params"', 4, function() {
4033
var value1 = 0,
4134
value2 = '\'quoted"/>&<\'value"',
@@ -48,9 +41,9 @@ asyncTest('link with "data-method" set to "post" and "data-params"', 4, function
4841
$('a[data-method]').attr({'data-method': 'post', 'data-params': JSON.stringify(params)});
4942
submit(function(data) {
5043
equal(data.REQUEST_METHOD, 'POST');
51-
equal(data.params.data1, escapeHTML(value1), 'params should have key data1 with right value');
52-
equal(data.params.data2, escapeHTML(value2), 'params should have key data2 with right value');
53-
propEqual(data.params.data3, {foo: {bar: {baz: escapeHTML(value2)}}}, 'params should have key data3 with right value');
44+
equal(data.params.data1, value1, 'params should have key data1 with right value');
45+
equal(data.params.data2, value2, 'params should have key data2 with right value');
46+
propEqual(data.params.data3, {foo: {bar: {baz: value2}}}, 'params should have key data3 with right value');
5447
});
5548
});
5649

test/server.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,10 @@ def jquery_versions
6161
content_type 'application/json'
6262
data.to_json
6363
elsif params[:iframe]
64-
payload = data.to_json.gsub('<', '&lt;').gsub('>', '&gt;')
6564
<<-HTML
6665
<script>
6766
if (window.top && window.top !== window)
68-
window.top.jQuery.event.trigger('iframe:loaded', #{payload})
67+
window.top.jQuery.event.trigger('iframe:loaded', #{data.to_json})
6968
</script>
7069
<p>You shouldn't be seeing this. <a href="#{request.env['HTTP_REFERER']}">Go back</a></p>
7170
HTML

0 commit comments

Comments
 (0)