diff --git a/source/Editor.js b/source/Editor.js
index f0c9a19..86eb771 100644
--- a/source/Editor.js
+++ b/source/Editor.js
@@ -1749,6 +1749,14 @@ proto.insertHTML = function ( html, isPaste ) {
}
// Parse HTML into DOM tree
div = this.createElement( 'DIV' );
+ // wrap with tr if html contains dangling td tags
+ if (html.match(/<\/td>((?!<\/tr>)[\s\S])*$/i)) {
+ html = '
' + html + '
';
+ }
+ // wrap with table if html contains dangling tr tags
+ if (html.match(/<\/tr>((?!<\/table>)[\s\S])*$/i)) {
+ html = '';
+ }
div.innerHTML = html;
frag = doc.createDocumentFragment();
frag.appendChild( empty( div ) );
diff --git a/test/squire.spec.js b/test/squire.spec.js
index a832ee0..fc6794b 100644
--- a/test/squire.spec.js
+++ b/test/squire.spec.js
@@ -351,6 +351,18 @@ describe('Squire RTE', function () {
})
});
+ describe('insertHTML', function() {
+ it('fix CF_HTML incomplete table', function() {
+ editor.insertHTML('');
+ expect(editor.getHTML(), 'to contain', '');
+
+ editor.setHTML('');
+
+ editor.insertHTML('');
+ expect(editor.getHTML(), 'to contain', '');
+ });
+ });
+
afterEach(function () {
editor = null;
var iframe = document.getElementById('testFrame');