Merge pull request #35652 from razh/revert-rails-ujs-html-content

Revert "Pass HTML responses as plain-text in rails-ujs"
This commit is contained in:
Kasper Timm Hansen 2019-03-18 11:50:55 +01:00 committed by GitHub
commit 014aa10fc0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View File

@ -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)

View File

@ -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')
})
})