@@ -9,8 +9,8 @@ namespace FlexConfirmMail.Dialog
9
9
{
10
10
public partial class MainDialog : Window
11
11
{
12
- private Outlook . MailItem _mail ;
13
- private List < RecipientInfo > _recipients ;
12
+ private Outlook . MailItem _mail ;
13
+ private List < RecipientInfo > _recipients ;
14
14
private List < RecipientInfo > _originalRecipients ;
15
15
private Config _config ;
16
16
@@ -29,9 +29,9 @@ internal MainDialog(Config config, Outlook.MailItem mail, List<RecipientInfo> or
29
29
QueueLogger . Log ( "===== Open MainDialog() =====" ) ;
30
30
31
31
// Show the subject string in title bar
32
- Title = $ "{ mail . Subject } - { Global . AppName } v{ Global . Version } { Global . Edition } ";
33
-
34
- // Set recipient info
32
+ Title = $ "{ mail . Subject } - { Global . AppName } v{ Global . Version } { Global . Edition } ";
33
+
34
+ // Set recipient info
35
35
List < RecipientInfo > recipients = new List < RecipientInfo > ( ) ;
36
36
37
37
foreach ( Outlook . Recipient recp in _mail . Recipients )
@@ -80,23 +80,23 @@ private void RenderMain()
80
80
}
81
81
}
82
82
83
- private bool CheckNewDomains ( )
84
- {
85
- if ( _originalRecipients == null )
86
- {
87
- return true ;
88
- }
89
- var originalDomains = _originalRecipients . Select ( _ => _ . Domain ) . ToHashSet ( ) ;
90
- var newDomainAddresses = _recipients
91
- . Where ( _ => ! originalDomains . Contains ( _ . Domain ) )
92
- . Select ( _ => _ . Address )
93
- . ToHashSet ( ) ;
94
- if ( newDomainAddresses . Count == 0 )
95
- {
96
- return true ;
97
- }
98
- var newDomainDialog = new NewDomainDialog ( newDomainAddresses ) ;
99
- return newDomainDialog . ShowDialog ( ) ?? false ;
83
+ private bool CheckNewDomains ( )
84
+ {
85
+ if ( _originalRecipients == null )
86
+ {
87
+ return true ;
88
+ }
89
+ var originalDomains = _originalRecipients . Select ( _ => _ . Domain ) . ToHashSet ( ) ;
90
+ var newDomainAddresses = _recipients
91
+ . Where ( _ => ! originalDomains . Contains ( _ . Domain ) )
92
+ . Select ( _ => _ . Address )
93
+ . ToHashSet ( ) ;
94
+ if ( newDomainAddresses . Count == 0 )
95
+ {
96
+ return true ;
97
+ }
98
+ var newDomainDialog = new NewDomainDialog ( newDomainAddresses ) ;
99
+ return newDomainDialog . ShowDialog ( ) ?? false ;
100
100
}
101
101
102
102
private bool IsEmbeddedImage ( Outlook . Attachment item )
@@ -147,18 +147,18 @@ private bool IsTrustedDomain(string domain)
147
147
return true ;
148
148
}
149
149
150
- try
150
+ try
151
151
{
152
152
return Regex . IsMatch ( domain , _config . TrustedDomainsPattern , RegexOptions . IgnoreCase ) ;
153
153
}
154
154
catch ( RegexMatchTimeoutException ) { }
155
155
156
156
return false ;
157
- }
158
-
157
+ }
158
+
159
159
private bool IsTrustedAddress ( string address )
160
160
{
161
- try
161
+ try
162
162
{
163
163
return Regex . IsMatch ( address , _config . TrustedAddressesPattern , RegexOptions . IgnoreCase ) ;
164
164
}
@@ -211,7 +211,7 @@ private void CheckUnsafeDomains(List<RecipientInfo> recipients)
211
211
{
212
212
if ( ! seen . Contains ( info . Domain ) )
213
213
{
214
- try
214
+ try
215
215
{
216
216
if ( Regex . IsMatch ( info . Domain , _config . UnsafeDomainsPattern , RegexOptions . IgnoreCase ) )
217
217
{
@@ -225,8 +225,8 @@ private void CheckUnsafeDomains(List<RecipientInfo> recipients)
225
225
seen . Add ( info . Domain ) ;
226
226
}
227
227
}
228
- }
229
-
228
+ }
229
+
230
230
private void CheckUnsafeAddresses ( List < RecipientInfo > recipients )
231
231
{
232
232
HashSet < string > seen = new HashSet < string > ( ) ;
@@ -235,7 +235,7 @@ private void CheckUnsafeAddresses(List<RecipientInfo> recipients)
235
235
{
236
236
if ( ! seen . Contains ( info . Address ) )
237
237
{
238
- try
238
+ try
239
239
{
240
240
if ( Regex . IsMatch ( info . Address , _config . UnsafeAddressesPattern , RegexOptions . IgnoreCase ) )
241
241
{
@@ -249,28 +249,28 @@ private void CheckUnsafeAddresses(List<RecipientInfo> recipients)
249
249
seen . Add ( info . Address ) ;
250
250
}
251
251
}
252
- }
252
+ }
253
253
254
254
private void CheckUnsafeFiles ( )
255
255
{
256
256
HashSet < string > notsafe = GetHashSet ( _config . UnsafeFiles ) ;
257
257
258
258
foreach ( Outlook . Attachment item in _mail . Attachments )
259
- {
259
+ {
260
260
HashSet < string > seen = new HashSet < string > ( ) ;
261
- try
261
+ try
262
262
{
263
263
foreach ( Match match in Regex . Matches ( item . FileName , _config . UnsafeFilesPattern , RegexOptions . IgnoreCase ) )
264
- {
265
- string lowerValue = match . Value . ToLower ( ) ;
266
- if ( seen . Contains ( lowerValue ) )
267
- {
268
- continue ;
269
- }
264
+ {
265
+ string lowerValue = match . Value . ToLower ( ) ;
266
+ if ( seen . Contains ( lowerValue ) )
267
+ {
268
+ continue ;
269
+ }
270
270
spFile . Children . Add ( GetWarnCheckBox (
271
271
string . Format ( Properties . Resources . MainUnsafeFilesWarning , match . Value ) ,
272
272
Properties . Resources . MainUnsafeFilesWarningHint
273
- ) ) ;
273
+ ) ) ;
274
274
seen . Add ( lowerValue ) ;
275
275
}
276
276
}
@@ -384,17 +384,17 @@ private void CheckBox_Click(object sender, RoutedEventArgs e)
384
384
}
385
385
386
386
private void ButtonOK_Click ( object sender , RoutedEventArgs e )
387
- {
388
- QueueLogger . Log ( "* Send button clicked." ) ;
389
- if ( _config . SafeNewDomainsEnabled )
390
- {
391
- QueueLogger . Log ( "* Check new domains" ) ;
392
- if ( ! CheckNewDomains ( ) )
393
- {
394
- return ;
395
- }
396
- }
397
-
387
+ {
388
+ QueueLogger . Log ( "* Send button clicked." ) ;
389
+ if ( _config . SafeNewDomainsEnabled )
390
+ {
391
+ QueueLogger . Log ( "* Check new domains" ) ;
392
+ if ( ! CheckNewDomains ( ) )
393
+ {
394
+ return ;
395
+ }
396
+ }
397
+
398
398
QueueLogger . Log ( "* closing..." ) ;
399
399
DialogResult = true ;
400
400
}
0 commit comments