Skip to content

Commit

Permalink
Merge branch 'main' into support_non_ascii_chars
Browse files Browse the repository at this point in the history
  • Loading branch information
Mohamed1226 authored Nov 14, 2023
2 parents 9268ccb + 83fcefb commit 28e2a81
Show file tree
Hide file tree
Showing 40 changed files with 1,296 additions and 502 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/dart.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

name: Dart

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

# Note: This workflow uses the latest stable version of the Dart SDK.
# You can specify other versions if desired, see documentation here:
# https://github.com/dart-lang/setup-dart/blob/main/README.md
# - uses: dart-lang/setup-dart@v1
- uses: dart-lang/setup-dart@9a04e6d73cca37bd455e0608d7e5092f881fd603

- name: Output dart version
run: dart --version

- name: Install dependencies
run: dart pub get

# Uncomment this step to verify the use of 'dart format' on each commit.
- name: Verify formatting
run: dart format --output=none --set-exit-if-changed .

# Consider passing '--fatal-infos' for slightly stricter analysis.
- name: Analyze project source
run: dart analyze

# Your project will need to have tests in test/ and a dependency on
# package:test for this step to succeed. Note that Flutter projects will
# want to change this to 'flutter test'.
- name: Run tests
run: dart test
21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
# 2.1.4
* Fix: use refreshed OAUTH tokens when using the high level MailClient API.
* Fix: handle edge cases in IMAP `FETCH` responses.
* Feat: Add details for low level IMAP errors when using the high level MailCLient API.
* Feat: Refresh OAUTH tokens 15 minutes in advance before they expire to reduce the risk of a token expiring during a long running operation.
* Feat: show error details when SMTP XOAuth2 authentication fails.
* Feat: synchronize access to low level clients when using the high level MailClient API.

# 2.1.3
* Fix: Apply correct mailbox path separator - thanks [nruzzu](https://github.com/nruzzu)!
* Feat: add firstWhereOrNull search method for a Tree
* Feat: add identityFlag getter to Mailbox

# 2.1.2
* Fix: RangeError when a Mailbox name contains a parentheses - thanks [nruzzu](https://github.com/nruzzu)
* Fix: base64 decoding of headers with a lowercase b
* Feat: support more name variations for ISO codecs
* Feat: update dependencies - thanks [hatch01](https://github.com/hatch01)
* Feat: use standard serialization based on json_serializable
* Feat: Improve high level API fetch message support

# 2.1.1
* Loosened dependency restrictions a bit upon suggestion from [hpoul](https://github.com/Enough-Software/enough_mail/issues/194)
* Added support for Big5, KOI8-r and KOI8-u character encodings
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ Transfer encodings:
* Test cases are in *test*.
* Please file a pull request for each improvement/fix that you are create - your contributions are welcome.
* Check out https://github.com/enough-Software/enough_mail/contribute for good first issues.
* When changing model files, re-run the code generation by calling `flutter pub run build_runner build --delete-conflicting-outputs`.
* When changing model files, re-run the code generation by calling `dart run build_runner build --delete-conflicting-outputs`.


## License
Expand Down
4 changes: 1 addition & 3 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ linter:
- cascade_invocations
- cast_nullable_to_non_nullable
- close_sinks
- collection_methods_unrelated_type
- comment_references
- constant_identifier_names
- control_flow_in_finally
Expand All @@ -63,12 +64,10 @@ linter:
#- flutter_style_todos # Flutter todos are to verbose for our requirements.
- hash_and_equals
- implementation_imports
- iterable_contains_unrelated_type
# - join_return_with_assignment # leads to less readable code IMHO
- library_names
- library_prefixes
- lines_longer_than_80_chars
- list_remove_unrelated_type
- literal_only_boolean_expressions
- no_adjacent_strings_in_list
- no_duplicate_case_values
Expand All @@ -93,7 +92,6 @@ linter:
- prefer_const_literals_to_create_immutables
- prefer_constructors_over_static_methods
- prefer_contains
- prefer_equal_for_default_values
- prefer_expression_function_bodies
- prefer_final_fields
- prefer_final_in_for_each
Expand Down
1 change: 1 addition & 0 deletions lib/src/codecs/base64_mail_codec.dart
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ class Base64MailCodec extends MailCodec {
}
cleaned = buffer.toString();
}

return base64.decode(cleaned);
}

Expand Down
1 change: 0 additions & 1 deletion lib/src/codecs/date_codec.dart
Original file line number Diff line number Diff line change
Expand Up @@ -542,5 +542,4 @@ Date and time values occur in several header fields. This section
return dateTime.toLocal();
}
// cSpell:enable

}
38 changes: 28 additions & 10 deletions lib/src/codecs/mail_codec.dart
Original file line number Diff line number Diff line change
Expand Up @@ -50,21 +50,36 @@ abstract class MailCodec {
'utf8': () => encodingUtf8,
'latin-1': () => encodingLatin1,
'iso-8859-1': () => encodingLatin1,
'iso8859-1': () => encodingLatin1,
'iso-8859-2': () => const Latin2Codec(allowInvalid: true),
'iso8859-2': () => const Latin2Codec(allowInvalid: true),
'iso-8859-3': () => const Latin3Codec(allowInvalid: true),
'iso8859-3': () => const Latin3Codec(allowInvalid: true),
'iso-8859-4': () => const Latin4Codec(allowInvalid: true),
'iso8859-4': () => const Latin4Codec(allowInvalid: true),
'iso-8859-5': () => const Latin5Codec(allowInvalid: true),
'iso8859-5': () => const Latin5Codec(allowInvalid: true),
'iso-8859-6': () => const Latin6Codec(allowInvalid: true),
'iso8859-6': () => const Latin6Codec(allowInvalid: true),
'iso-8859-7': () => const Latin7Codec(allowInvalid: true),
'iso8859-7': () => const Latin7Codec(allowInvalid: true),
'iso-8859-8': () => const Latin8Codec(allowInvalid: true),
'iso8859-8': () => const Latin8Codec(allowInvalid: true),
'iso-8859-9': () => const Latin9Codec(allowInvalid: true),
'iso8859-9': () => const Latin9Codec(allowInvalid: true),
'iso-8859-10': () => const Latin10Codec(allowInvalid: true),
'iso8859-10': () => const Latin10Codec(allowInvalid: true),
'iso-8859-11': () => const Latin11Codec(allowInvalid: true),
'iso8859-11': () => const Latin11Codec(allowInvalid: true),
// iso-8859-12 does not exist...
'iso-8859-13': () => const Latin13Codec(allowInvalid: true),
'iso8859-13': () => const Latin13Codec(allowInvalid: true),
'iso-8859-14': () => const Latin14Codec(allowInvalid: true),
'iso8859-14': () => const Latin14Codec(allowInvalid: true),
'iso-8859-15': () => const Latin15Codec(allowInvalid: true),
'iso8859-15': () => const Latin15Codec(allowInvalid: true),
'iso-8859-16': () => const Latin16Codec(allowInvalid: true),
'iso8859-16': () => const Latin16Codec(allowInvalid: true),
'windows-1250': () => const Windows1250Codec(allowInvalid: true),
'cp1250': () => const Windows1250Codec(allowInvalid: true),
'cp-1250': () => const Windows1250Codec(allowInvalid: true),
Expand Down Expand Up @@ -102,10 +117,12 @@ abstract class MailCodec {
'us-ascii': () => encodingAscii,
'ascii': () => encodingAscii,
};
static final _textDecodersByName = <
String,
String Function(String text, convert.Encoding encoding,
{required bool isHeader})>{
static final _textDecodersByName = <String,
String Function(
String text,
convert.Encoding encoding, {
required bool isHeader,
})>{
'q': quotedPrintable.decodeText,
'quoted-printable': quotedPrintable.decodeText,
'b': base64.decodeText,
Expand Down Expand Up @@ -181,7 +198,7 @@ abstract class MailCodec {
: containsEncodedWordsWithTab
? '?=\t$startSequence'
: '?=$startSequence';
if (startSequence.endsWith('?B?')) {
if (startSequence.endsWith('?B?') || startSequence.endsWith('?b?')) {
// in base64 encoding there are 2 cases:
// 1. individual parts can end with the padding character "=":
// - in that case we just remove the
Expand Down Expand Up @@ -257,15 +274,16 @@ abstract class MailCodec {
return HeaderEncoding.none;
}
final group = match.group(0);
if (group?.contains('?B?') ?? false) {
return HeaderEncoding.B;
}
return HeaderEncoding.Q;
return group?.contains('?B?') ?? group?.contains('?b?') ?? false
? HeaderEncoding.B
: HeaderEncoding.Q;
}

/// Decodes the given binary [text]
static Uint8List decodeBinary(
final String text, final String? transferEncoding) {
final String text,
final String? transferEncoding,
) {
final tEncoding = transferEncoding ?? contentTransferEncodingNone;
final decoder = _binaryDecodersByName[tEncoding.toLowerCase()];
if (decoder == null) {
Expand Down
2 changes: 1 addition & 1 deletion lib/src/discover/discover.dart
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ class Discover {
}

// try to guess incoming and outgoing server names based on the domain
final domains = hasMxDomain ? [emailDomain, mxDomain!] : [emailDomain];
final domains = hasMxDomain ? [emailDomain, mxDomain] : [emailDomain];
config ??= await DiscoverHelper.discoverFromCommonDomains(domains,
isLogEnabled: isLogEnabled);
}
Expand Down
Loading

0 comments on commit 28e2a81

Please sign in to comment.