Skip to content

Commit

Permalink
improve code style and keep casing of filename
Browse files Browse the repository at this point in the history
  • Loading branch information
robert-virkus committed Apr 10, 2021
1 parent 73593eb commit a8cff5f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
26 changes: 13 additions & 13 deletions lib/mime_message.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1225,7 +1225,7 @@ class ParameterizedHeader {

void renderRemainingFields(StringBuffer buffer, {List<String>? exclude}) {
for (final key in parameters.keys) {
if (!exclude!.contains(key.toLowerCase())) {
if (exclude == null || !exclude.contains(key.toLowerCase())) {
renderField(key, parameters[key], false, buffer);
}
}
Expand Down Expand Up @@ -1272,19 +1272,19 @@ class ContentTypeHeader extends ParameterizedHeader {
}

@override
void setParameter(String name, String? quotedValue) {
void setParameter(String name, String quotedValue) {
name = name.toLowerCase();
if (name == 'charset') {
quotedValue = removeQuotes(quotedValue!).toLowerCase();
quotedValue = removeQuotes(quotedValue).toLowerCase();
charset = quotedValue;
} else if (name == 'boundary') {
quotedValue = removeQuotes(quotedValue!);
quotedValue = removeQuotes(quotedValue);
boundary = quotedValue;
} else if (name == 'format') {
quotedValue = removeQuotes(quotedValue!).toLowerCase();
quotedValue = removeQuotes(quotedValue).toLowerCase();
isFlowedFormat = (quotedValue == 'flowed');
}
super.setParameter(name, quotedValue!);
super.setParameter(name, quotedValue);
}

static ContentTypeHeader from(MediaType mediaType,
Expand Down Expand Up @@ -1384,24 +1384,24 @@ class ContentDispositionHeader extends ParameterizedHeader {
}

@override
void setParameter(String name, String? quotedValue) {
void setParameter(String name, String quotedValue) {
name = name.toLowerCase();
if (name == 'filename') {
quotedValue = removeQuotes(quotedValue!).toLowerCase();
quotedValue = removeQuotes(quotedValue);
filename = quotedValue;
} else if (name == 'creation-date') {
quotedValue = removeQuotes(quotedValue!);
quotedValue = removeQuotes(quotedValue);
creationDate = DateCodec.decodeDate(quotedValue);
} else if (name == 'modification-date') {
quotedValue = removeQuotes(quotedValue!);
quotedValue = removeQuotes(quotedValue);
modificationDate = DateCodec.decodeDate(quotedValue);
} else if (name == 'read-date') {
quotedValue = removeQuotes(quotedValue!);
quotedValue = removeQuotes(quotedValue);
readDate = DateCodec.decodeDate(quotedValue);
} else if (name == 'size') {
size = int.tryParse(quotedValue!);
size = int.tryParse(quotedValue);
}
super.setParameter(name, quotedValue!);
super.setParameter(name, quotedValue);
}
}

Expand Down
4 changes: 2 additions & 2 deletions test/smtp/smtp_client_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import 'mock_smtp_server.dart';

late SmtpClient client;
bool _isLogEnabled = false;
String? _smtpUser;
String? _smtpPassword;
late String _smtpUser;
late String _smtpPassword;
late MockSmtpServer _mockServer;

void main() {
Expand Down

0 comments on commit a8cff5f

Please sign in to comment.