TF-2602 Set charset for attachment with mimeType=text/plain when sent email on web
This commit is contained in:
+14
-6
@@ -337,10 +337,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: flutter_charset_detector
|
||||
sha256: "45de8a4b4255c1ea850a30955e7456091899ed4ff8b75593e14ec59f629b4b56"
|
||||
sha256: "5d4796d43dac2f37e14149b0f0c676fa08e8eb1ada8e99342a838d971d2fb9b1"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.0.0"
|
||||
version: "3.0.0"
|
||||
flutter_charset_detector_android:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -349,14 +349,14 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.1.1"
|
||||
flutter_charset_detector_ios:
|
||||
flutter_charset_detector_darwin:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: flutter_charset_detector_ios
|
||||
sha256: e0e2c7b819cd1f7c9a50da94bf7f0e6d7a095eb64e81196ec758e77793903d43
|
||||
name: flutter_charset_detector_darwin
|
||||
sha256: daac20390275efb92fbb14350fe11286c5e29c7b80d6b0867f52d760f0d69763
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.0.2"
|
||||
version: "1.1.0"
|
||||
flutter_charset_detector_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -365,6 +365,14 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.1.0"
|
||||
flutter_charset_detector_web:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: flutter_charset_detector_web
|
||||
sha256: d8495115abada771c75f9395aae3e5809ffd506e8fc8f62b403ae11fc29e1d2b
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.0.2"
|
||||
flutter_image_compress:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
||||
@@ -9,7 +9,7 @@ import 'package:flutter_charset_detector/flutter_charset_detector.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
|
||||
class FileUtils {
|
||||
static const String DEFAULT_CHARSET = 'UTF-8';
|
||||
static const String DEFAULT_CHARSET = 'uft-8';
|
||||
static const String TEXT_PLAIN_MIME_TYPE = 'text/plain';
|
||||
|
||||
Future<String> _getInternalStorageDirPath({
|
||||
@@ -139,14 +139,13 @@ class FileUtils {
|
||||
}
|
||||
}
|
||||
|
||||
Future<String> getFileCharset(String filePath) async {
|
||||
Future<String> getCharsetFromBytes(Uint8List bytes) async {
|
||||
try {
|
||||
final file = File(filePath);
|
||||
final decodingResult = await CharsetDetector.autoDecode(file.readAsBytesSync());
|
||||
logError('FileUtils::getFileCharset: FILE_CHARSET = ${decodingResult.charset}');
|
||||
return decodingResult.charset;
|
||||
final decodedResult = await CharsetDetector.autoDecode(bytes);
|
||||
log('FileUtils::getCharsetFromBytes: FILE_CHARSET = ${decodedResult.charset}');
|
||||
return decodedResult.charset;
|
||||
} catch (e) {
|
||||
logError('FileUtils::getFileCharset: Exception: $e');
|
||||
logError('FileUtils::getCharsetFromBytes: Exception: $e');
|
||||
return DEFAULT_CHARSET;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import 'dart:js' as js;
|
||||
import 'package:universal_html/js.dart' as js;
|
||||
|
||||
/// Whether the CanvasKit renderer is being used on web.
|
||||
///
|
||||
|
||||
+14
-6
@@ -330,10 +330,10 @@ packages:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: flutter_charset_detector
|
||||
sha256: "45de8a4b4255c1ea850a30955e7456091899ed4ff8b75593e14ec59f629b4b56"
|
||||
sha256: "5d4796d43dac2f37e14149b0f0c676fa08e8eb1ada8e99342a838d971d2fb9b1"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.0.0"
|
||||
version: "3.0.0"
|
||||
flutter_charset_detector_android:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -342,14 +342,14 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.0.1"
|
||||
flutter_charset_detector_ios:
|
||||
flutter_charset_detector_darwin:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: flutter_charset_detector_ios
|
||||
sha256: e0e2c7b819cd1f7c9a50da94bf7f0e6d7a095eb64e81196ec758e77793903d43
|
||||
name: flutter_charset_detector_darwin
|
||||
sha256: d17c1847366a0501449d95d18a43417585841afe10200ceefb4422e6b7fccefb
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.0.2"
|
||||
version: "1.0.0"
|
||||
flutter_charset_detector_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -358,6 +358,14 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.0.0"
|
||||
flutter_charset_detector_web:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: flutter_charset_detector_web
|
||||
sha256: d8495115abada771c75f9395aae3e5809ffd506e8fc8f62b403ae11fc29e1d2b
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.0.2"
|
||||
flutter_image_compress:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
|
||||
+1
-1
@@ -79,7 +79,7 @@ dependencies:
|
||||
|
||||
fk_user_agent: 2.1.0
|
||||
|
||||
flutter_charset_detector: 2.0.0
|
||||
flutter_charset_detector: 3.0.0
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
|
||||
+6
-5
@@ -90,8 +90,9 @@ PODS:
|
||||
- flutter_appauth (0.0.1):
|
||||
- AppAuth (= 1.7.4)
|
||||
- Flutter
|
||||
- flutter_charset_detector_ios (0.0.1):
|
||||
- flutter_charset_detector_darwin (0.0.1):
|
||||
- Flutter
|
||||
- FlutterMacOS
|
||||
- UniversalDetector2 (= 2.0.1)
|
||||
- flutter_downloader (0.0.1):
|
||||
- Flutter
|
||||
@@ -205,7 +206,7 @@ DEPENDENCIES:
|
||||
- fk_user_agent (from `.symlinks/plugins/fk_user_agent/ios`)
|
||||
- Flutter (from `Flutter`)
|
||||
- flutter_appauth (from `.symlinks/plugins/flutter_appauth/ios`)
|
||||
- flutter_charset_detector_ios (from `.symlinks/plugins/flutter_charset_detector_ios/ios`)
|
||||
- flutter_charset_detector_darwin (from `.symlinks/plugins/flutter_charset_detector_darwin/darwin`)
|
||||
- flutter_downloader (from `.symlinks/plugins/flutter_downloader/ios`)
|
||||
- flutter_image_compress_common (from `.symlinks/plugins/flutter_image_compress_common/ios`)
|
||||
- flutter_inappwebview_ios (from `.symlinks/plugins/flutter_inappwebview_ios/ios`)
|
||||
@@ -273,8 +274,8 @@ EXTERNAL SOURCES:
|
||||
:path: Flutter
|
||||
flutter_appauth:
|
||||
:path: ".symlinks/plugins/flutter_appauth/ios"
|
||||
flutter_charset_detector_ios:
|
||||
:path: ".symlinks/plugins/flutter_charset_detector_ios/ios"
|
||||
flutter_charset_detector_darwin:
|
||||
:path: ".symlinks/plugins/flutter_charset_detector_darwin/darwin"
|
||||
flutter_downloader:
|
||||
:path: ".symlinks/plugins/flutter_downloader/ios"
|
||||
flutter_image_compress_common:
|
||||
@@ -333,7 +334,7 @@ SPEC CHECKSUMS:
|
||||
fk_user_agent: 1f47ec39291e8372b1d692b50084b0d54103c545
|
||||
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
|
||||
flutter_appauth: 1ce438877bc111c5d8f42da47729909290624886
|
||||
flutter_charset_detector_ios: 5157d0104855b9deb78e1395515a287197bc2d55
|
||||
flutter_charset_detector_darwin: fb3692d6d72cb6afcce7b0dd1a9516be6e78556e
|
||||
flutter_downloader: b7301ae057deadd4b1650dc7c05375f10ff12c39
|
||||
flutter_image_compress_common: ec1d45c362c9d30a3f6a0426c297f47c52007e3e
|
||||
flutter_inappwebview_ios: 97215cf7d4677db55df76782dbd2930c5e1c1ea0
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'package:core/data/network/dio_client.dart';
|
||||
import 'package:core/data/network/download/download_client.dart';
|
||||
import 'package:core/utils/application_manager.dart';
|
||||
import 'package:core/utils/file_utils.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:jmap_dart_client/http/http_client.dart';
|
||||
import 'package:tmail_ui_user/features/base/base_bindings.dart';
|
||||
@@ -38,7 +39,10 @@ class PublicAssetBindings extends BaseBindings {
|
||||
@override
|
||||
void dependencies() {
|
||||
Get.lazyPut(
|
||||
() => FileUploader(Get.find<DioClient>(tag: BindingTag.isolateTag), Get.find<Executor>()),
|
||||
() => FileUploader(
|
||||
Get.find<DioClient>(tag: BindingTag.isolateTag),
|
||||
Get.find<Executor>(),
|
||||
Get.find<FileUtils>()),
|
||||
tag: BindingTag.publicAssetBindingsTag);
|
||||
Get.lazyPut(
|
||||
() => PublicAssetApi(Get.find<HttpClient>(), Get.find<Uuid>()),
|
||||
|
||||
@@ -123,11 +123,13 @@ class FileUploader {
|
||||
);
|
||||
log('FileUploader::_handleUploadAttachmentAction(): RESULT_JSON = $resultJson');
|
||||
if (argsUpload.mobileFileUpload.mimeType == FileUtils.TEXT_PLAIN_MIME_TYPE) {
|
||||
final fileCharset = await argsUpload.fileUtils.getFileCharset(argsUpload.mobileFileUpload.filePath);
|
||||
final fileCharset = await argsUpload.fileUtils.getCharsetFromBytes(
|
||||
File(argsUpload.mobileFileUpload.filePath).readAsBytesSync()
|
||||
);
|
||||
return _parsingResponse(
|
||||
resultJson: resultJson,
|
||||
fileName: argsUpload.mobileFileUpload.fileName,
|
||||
fileCharset: fileCharset);
|
||||
fileCharset: fileCharset.toLowerCase());
|
||||
} else {
|
||||
return _parsingResponse(
|
||||
resultJson: resultJson,
|
||||
@@ -140,7 +142,7 @@ class FileUploader {
|
||||
requestOptions: exception.requestOptions.copyWith(data: ''));
|
||||
} catch (exception) {
|
||||
logError('FileUploader::_handleUploadAttachmentAction():OtherException: $exception');
|
||||
|
||||
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
@@ -181,8 +183,18 @@ class FileUploader {
|
||||
);
|
||||
}
|
||||
);
|
||||
log('FileUploader::_handleUploadAttachmentActionOnWeb():resultJson: $resultJson');
|
||||
return _parsingResponse(resultJson: resultJson, fileName: fileInfo.fileName);
|
||||
log('FileUploader::_handleUploadAttachmentActionOnWeb(): RESULT_JSON = $resultJson');
|
||||
if (fileInfo.mimeType == FileUtils.TEXT_PLAIN_MIME_TYPE) {
|
||||
final fileCharset = await _fileUtils.getCharsetFromBytes(fileInfo.bytes!);
|
||||
return _parsingResponse(
|
||||
resultJson: resultJson,
|
||||
fileName: fileInfo.fileName,
|
||||
fileCharset: fileCharset.toLowerCase());
|
||||
} else {
|
||||
return _parsingResponse(
|
||||
resultJson: resultJson,
|
||||
fileName: fileInfo.fileName);
|
||||
}
|
||||
}
|
||||
|
||||
static Attachment _parsingResponse({
|
||||
|
||||
+14
-6
@@ -337,10 +337,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: flutter_charset_detector
|
||||
sha256: "45de8a4b4255c1ea850a30955e7456091899ed4ff8b75593e14ec59f629b4b56"
|
||||
sha256: "5d4796d43dac2f37e14149b0f0c676fa08e8eb1ada8e99342a838d971d2fb9b1"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.0.0"
|
||||
version: "3.0.0"
|
||||
flutter_charset_detector_android:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -349,14 +349,14 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.1.1"
|
||||
flutter_charset_detector_ios:
|
||||
flutter_charset_detector_darwin:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: flutter_charset_detector_ios
|
||||
sha256: e0e2c7b819cd1f7c9a50da94bf7f0e6d7a095eb64e81196ec758e77793903d43
|
||||
name: flutter_charset_detector_darwin
|
||||
sha256: daac20390275efb92fbb14350fe11286c5e29c7b80d6b0867f52d760f0d69763
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.0.2"
|
||||
version: "1.1.0"
|
||||
flutter_charset_detector_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -365,6 +365,14 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.1.0"
|
||||
flutter_charset_detector_web:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: flutter_charset_detector_web
|
||||
sha256: d8495115abada771c75f9395aae3e5809ffd506e8fc8f62b403ae11fc29e1d2b
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.0.2"
|
||||
flutter_image_compress:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
||||
+14
-6
@@ -659,10 +659,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: flutter_charset_detector
|
||||
sha256: "45de8a4b4255c1ea850a30955e7456091899ed4ff8b75593e14ec59f629b4b56"
|
||||
sha256: "5d4796d43dac2f37e14149b0f0c676fa08e8eb1ada8e99342a838d971d2fb9b1"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.0.0"
|
||||
version: "3.0.0"
|
||||
flutter_charset_detector_android:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -671,14 +671,14 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.0.1"
|
||||
flutter_charset_detector_ios:
|
||||
flutter_charset_detector_darwin:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: flutter_charset_detector_ios
|
||||
sha256: e0e2c7b819cd1f7c9a50da94bf7f0e6d7a095eb64e81196ec758e77793903d43
|
||||
name: flutter_charset_detector_darwin
|
||||
sha256: d17c1847366a0501449d95d18a43417585841afe10200ceefb4422e6b7fccefb
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.0.2"
|
||||
version: "1.0.0"
|
||||
flutter_charset_detector_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -687,6 +687,14 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.0.0"
|
||||
flutter_charset_detector_web:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: flutter_charset_detector_web
|
||||
sha256: d8495115abada771c75f9395aae3e5809ffd506e8fc8f62b403ae11fc29e1d2b
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.0.2"
|
||||
flutter_colorpicker:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
||||
@@ -7,6 +7,7 @@ import 'package:core/presentation/utils/responsive_utils.dart';
|
||||
import 'package:core/utils/application_manager.dart';
|
||||
import 'package:core/utils/platform_info.dart';
|
||||
import 'package:dartz/dartz.dart' hide State;
|
||||
import 'package:core/utils/file_utils.dart';
|
||||
import 'package:flutter/widgets.dart' hide State;
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:get/get.dart';
|
||||
@@ -74,6 +75,7 @@ import 'identity_creator_controller_test.mocks.dart';
|
||||
MockSpec<IdentityUtils>(),
|
||||
MockSpec<DioClient>(),
|
||||
MockSpec<Executor>(),
|
||||
MockSpec<FileUtils>(),
|
||||
MockSpec<RemoteExceptionThrower>(),
|
||||
MockSpec<DownloadClient>(),
|
||||
MockSpec<HtmlAnalyzer>(),
|
||||
@@ -155,6 +157,7 @@ void main() {
|
||||
|
||||
Get.put<DioClient>(MockDioClient(), tag: BindingTag.isolateTag);
|
||||
Get.put<Executor>(MockExecutor());
|
||||
Get.put<FileUtils>(MockFileUtils());
|
||||
Get.put<RemoteExceptionThrower>(MockRemoteExceptionThrower());
|
||||
Get.put<DownloadClient>(MockDownloadClient());
|
||||
Get.put<HtmlAnalyzer>(MockHtmlAnalyzer());
|
||||
@@ -182,7 +185,7 @@ void main() {
|
||||
true,
|
||||
{CapabilityIdentifier.jmapPublicAsset: DefaultCapability({})});
|
||||
final session = Session(
|
||||
{},
|
||||
{},
|
||||
{accountId: account},
|
||||
{}, UserName('value'), Uri(), Uri(), Uri(), Uri(), State('value'));
|
||||
|
||||
@@ -271,14 +274,14 @@ void main() {
|
||||
final context = MockBuildContext();
|
||||
identityCreatorController.updateNameIdentity(context, identityName);
|
||||
identityCreatorController.updateContentHtmlEditor(htmlContent);
|
||||
|
||||
|
||||
identityCreatorController.onUnloadBrowserListener(Event(''));
|
||||
await untilCalled(mockSaveIdentityCacheOnWebInteractor.execute(
|
||||
any,
|
||||
any,
|
||||
identityCache: anyNamed('identityCache'),
|
||||
));
|
||||
|
||||
|
||||
// assert
|
||||
verify(mockSaveIdentityCacheOnWebInteractor.execute(
|
||||
accountId,
|
||||
@@ -321,14 +324,14 @@ void main() {
|
||||
final context = MockBuildContext();
|
||||
identityCreatorController.updateNameIdentity(context, identityName);
|
||||
identityCreatorController.updateContentHtmlEditor(htmlContent);
|
||||
|
||||
|
||||
identityCreatorController.onBeforeReconnect();
|
||||
await untilCalled(mockSaveIdentityCacheOnWebInteractor.execute(
|
||||
any,
|
||||
any,
|
||||
identityCache: anyNamed('identityCache'),
|
||||
));
|
||||
|
||||
|
||||
// assert
|
||||
verify(mockSaveIdentityCacheOnWebInteractor.execute(
|
||||
accountId,
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" name="viewport">
|
||||
|
||||
<script type="application/javascript" src="assets/packages/flutter_inappwebview_web/assets/web/web_support.js" defer></script>
|
||||
<script type="application/javascript" src="assets/packages/flutter_charset_detector_web/assets/web/jschardet.min.js" defer></script>
|
||||
<script src="splash/splash.js"></script>
|
||||
<script src="worker_service/worker_service.js"></script>
|
||||
<script src="i18n/translater.js"></script>
|
||||
|
||||
Reference in New Issue
Block a user