diff --git a/core/lib/data/network/download/download_client.dart b/core/lib/data/network/download/download_client.dart index e3e6461d8..d18917f28 100644 --- a/core/lib/data/network/download/download_client.dart +++ b/core/lib/data/network/download/download_client.dart @@ -119,7 +119,7 @@ class DownloadClient { fileName = fileName.split('.').first; } mimeType = HtmlUtils.validateHtmlImageResourceMimeType(mimeType); - final base64Uri = '$fileName'; + final base64Uri = '$fileName'; return base64Uri; } } \ No newline at end of file diff --git a/core/lib/utils/html/html_interaction.dart b/core/lib/utils/html/html_interaction.dart index 63a6104e7..d7308fb20 100644 --- a/core/lib/utils/html/html_interaction.dart +++ b/core/lib/utils/html/html_interaction.dart @@ -158,22 +158,9 @@ class HtmlInteraction { function normalizeStyleAttribute(attrs) { // Normalize style attribute to ensure proper responsive behavior let style = attrs['style']; - const widthStr = attrs['width']; if (!style) { - if (!widthStr) { - attrs['style'] = 'max-width: 100%;height: auto;display: inline;'; - } else { - if (!style.includes('height')) { - style += 'height: auto;'; - } - - if (!style.includes('display')) { - style += 'display: inline;'; - } - - attrs['style'] = style; - } + attrs['style'] = 'max-width:100%;height:auto;display:inline;'; return; } @@ -199,15 +186,15 @@ class HtmlInteraction { // Add responsive defaults if missing if (!style.includes('max-width')) { - style += 'max-width: 100%;'; + style += 'max-width:100%;'; } if (!style.includes('height')) { - style += 'height: auto;'; + style += 'height:auto;'; } if (!style.includes('display')) { - style += 'display: inline;'; + style += 'display:inline;'; } attrs['style'] = style; diff --git a/integration_test/scenarios/email_detailed/deformed_inlined_image_scenario.dart b/integration_test/scenarios/email_detailed/deformed_inlined_image_scenario.dart index 4b0073823..2e25e7400 100644 --- a/integration_test/scenarios/email_detailed/deformed_inlined_image_scenario.dart +++ b/integration_test/scenarios/email_detailed/deformed_inlined_image_scenario.dart @@ -19,10 +19,20 @@ class DeformedInlinedImageScenario extends BaseTestScenario { src="https://example.com/image.jpg" alt="inline-image-no-style"/>
+ inline-image-oversize-with-style-have-full-whitespaces +
inline-image-oversize-with-style + alt="inline-image-oversize-with-style-have-whitespaces"/> +
+ inline-image-oversize-with-style-no-whitespaces
inline-image-oversize-with-width-attribute
+ inline-image-oversize-with-style-and-width-attribute-have-full-whitespaces +
inline-image-oversize-with-style-and-width-attribute + alt="inline-image-oversize-with-style-and-width-attribute-have-whitespaces"/> +
+ inline-image-oversize-with-style-and-width-attribute-no-whitespaces
inline-image-normal-size-with-width-attribute
+ inline-image-normal-size-with-style-and-width-attribute-have-full-whitespaces +
inline-image-normal-size-with-style-and-width-attribute + alt="inline-image-normal-size-with-style-and-width-attribute-have-whitespaces"/> +
+ inline-image-normal-size-with-style-and-width-attribute-no-whitespaces '''; @override @@ -126,29 +164,34 @@ class DeformedInlinedImageScenario extends BaseTestScenario { final imageList = List>.from(result); - expect(imageList.length, 6); + expect(imageList.length, 12); for (var img in imageList) { final imgWidth= img['width']; final imgHeight = img['height']; final imgStyle = img['style']; - final imgAlt = img['alt']; + final imgAlt = img['alt'] as String; final imgOuterHTML = img['outerHTML']; log("DeformedInlinedImageScenario::_expectEmailViewDisplaysNormalizedInlineImages:Image $imgOuterHTML"); + expect(imgStyle.contains('max-width:100%'), isTrue); + expect(imgStyle.contains('display:inline'), isTrue); + expect(imgStyle.contains('height:'), isTrue); - if (imgAlt == 'inline-image-normal-size-with-width-attribute') { - expect(imgStyle, isNull); - expect(imgWidth, equals('100')); - expect(imgHeight, equals('100')); - } else if (imgAlt == 'inline-image-normal-size-with-style-and-width-attribute') { - expect(imgStyle.contains('width: 100px;height: 100px;'), isTrue); - expect(imgWidth, equals('100')); - expect(imgHeight, equals('100')); - } else { - expect(imgStyle, equals('max-width: 100%;height: auto;display: inline;')); + if (imgAlt.startsWith('inline-image-normal-size')) { + expect(imgWidth, isNotNull); + expect(imgHeight, isNotNull); + } else if (imgAlt.startsWith('inline-image-oversize')) { expect(imgWidth, isNull); expect(imgHeight, isNull); } + + if (imgAlt.startsWith('inline-image-normal-size-with-style-and-width-attribute')) { + expect(imgStyle.contains('width:'), isTrue); + expect(imgStyle.contains('100px'), isTrue); + } else if (imgAlt.startsWith('inline-image-oversize-with-style-and-width-attribute')) { + expect(imgStyle.contains('style="width:2000px'), isFalse); + expect(imgStyle.contains('style="width: 2000px'), isFalse); + } } } } \ No newline at end of file diff --git a/lib/features/composer/presentation/controller/rich_text_web_controller.dart b/lib/features/composer/presentation/controller/rich_text_web_controller.dart index 2eff51dff..5d6f22f2c 100644 --- a/lib/features/composer/presentation/controller/rich_text_web_controller.dart +++ b/lib/features/composer/presentation/controller/rich_text_web_controller.dart @@ -284,7 +284,7 @@ class RichTextWebController extends BaseRichTextController { final base64Data = base64Encode(platformFile.bytes!); final mimeType = HtmlUtils.validateHtmlImageResourceMimeType('image/${platformFile.extension}'); editorController.insertHtml( - 'Image in my signature' + 'Image in my signature' ); } else { logError("RichTextWebController::insertImageAsBase64: bytes is null"); diff --git a/lib/features/public_asset/presentation/public_asset_controller.dart b/lib/features/public_asset/presentation/public_asset_controller.dart index f79d6b79f..4b50d91b0 100644 --- a/lib/features/public_asset/presentation/public_asset_controller.dart +++ b/lib/features/public_asset/presentation/public_asset_controller.dart @@ -186,7 +186,7 @@ class PublicAssetController extends BaseController { newlyPickedPublicAssetIds.add(publicAsset.id!); final imageTag = ''; if (PlatformInfo.isWeb) { Get