Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Pass HTML responses as plain-text in rails-ujs" #35652

Merged
merged 2 commits into from
Mar 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ processResponse = (response, type) ->
script.setAttribute('nonce', cspNonce())
script.text = response
document.head.appendChild(script).parentNode.removeChild(script)
else if type.match(/\bxml\b/)
else if type.match(/\b(xml|html|svg)\b/)
parser = new DOMParser()
type = type.replace(/;.+/, '') # remove something like ';charset=utf-8'
try response = parser.parseFromString(response, type)
Expand Down
4 changes: 2 additions & 2 deletions actionview/test/ujs/public/test/call-remote.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,14 @@ asyncTest('execution of JS code does not modify current DOM', 1, function() {
})
})

asyncTest('HTML content should be plain-text', 1, function() {
asyncTest('HTML document should be parsed', 1, function() {
buildForm({ method: 'post', 'data-type': 'html' })

$('form').append('<input type="text" name="content_type" value="text/html">')
$('form').append('<input type="text" name="content" value="<p>hello</p>">')

submit(function(e, data, status, xhr) {
ok(data === '<p>hello</p>', 'returned data should be a plain-text string')
ok(data instanceof HTMLDocument, 'returned data should be an HTML document')
})
})

Expand Down