diff --git a/src/model/encoding/__tests__/convertFromHTMLToContentBlocks-test.js b/src/model/encoding/__tests__/convertFromHTMLToContentBlocks-test.js index d0d6f6ece1..db7cd1baab 100644 --- a/src/model/encoding/__tests__/convertFromHTMLToContentBlocks-test.js +++ b/src/model/encoding/__tests__/convertFromHTMLToContentBlocks-test.js @@ -15,6 +15,9 @@ jest.disableAutomock(); const convertFromHTMLToContentBlocks = require('convertFromHTMLToContentBlocks'); +const IMAGE_DATA_URL = 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///' + + 'yH5BAEAAAAALAAAAAABAAEAAAIBRAA7'; + function testConvertingAdjacentHtmlElementsToContentBlocks( tag: string, ) { @@ -45,4 +48,20 @@ describe('convertFromHTMLToContentBlocks', () => { 'p', 'pre', ].forEach(tag => testConvertingAdjacentHtmlElementsToContentBlocks(tag)); + + describe('img tag', function() { + test('img with http protocol should have empty content', function() { + const blocks = convertFromHTMLToContentBlocks( + '', + ); + expect(blocks.contentBlocks[0].text).toBe(' '); + }); + + test('img with data protocol should be correctly parsed', function() { + const blocks = convertFromHTMLToContentBlocks( + ``, + ); + expect(blocks.contentBlocks[0].text).toBe(' '); + }); + }); }); diff --git a/src/model/encoding/convertFromHTMLToContentBlocks.js b/src/model/encoding/convertFromHTMLToContentBlocks.js index 2ddafa78ac..d92283d953 100644 --- a/src/model/encoding/convertFromHTMLToContentBlocks.js +++ b/src/model/encoding/convertFromHTMLToContentBlocks.js @@ -403,8 +403,9 @@ function genFragment( entityConfig[attr] = imageAttribute; } }); - const imageURI = new URI(entityConfig.src).toString(); - node.textContent = imageURI; // Output src if no decorator + // Forcing this node to have children because otherwise no entity will be + // created for this node. + node.textContent = ' '; // TODO: update this when we remove DraftEntity entirely inEntity = DraftEntity.__create(