Fixes Javascript crash when plain text is pasted as html (e. g. a phone number without html tags) into rich text field. Follow up for #2645.

This commit is contained in:
Mantas Masalskis 2019-11-27 14:40:30 +01:00 committed by Martin Edenhofer
parent a9dd937968
commit f41aa097ce

View file

@ -290,7 +290,11 @@
// E.g. Excel provides images of the spreadsheet along with HTML.
// While some browsers make images available in clipboard as HTML,
// sometimes wrapped in multiple nodes.
if($(clipboardData.getData('text/html')).text().trim().length == 0) {
var rawHTML = clipboardData.getData('text/html')
var parsedHTML = jQuery(jQuery.parseHTML(rawHTML))
if(parsedHTML.text().trim().length == 0) {
item = jQuery.grep(clipboardData.items, function(item){
return item.kind == 'file' && (item.type == 'image/png' || item.type == 'image/jpeg')
})[0]