@@ -282,15 +282,15 @@ private void AnalyzeFile(string filePath)
282282 {
283283 foreach ( string rule in includeRule )
284284 {
285- Regex includeRegex = new Regex ( rule . Replace ( " *", ".*?" ) , RegexOptions . IgnoreCase ) ;
285+ Regex includeRegex = new Regex ( String . Format ( "^{0}$" , Regex . Escape ( rule ) . Replace ( @"\ *", ".*" ) ) , RegexOptions . IgnoreCase ) ;
286286 includeRegexList . Add ( includeRegex ) ;
287287 }
288288 }
289289 if ( excludeRule != null )
290290 {
291291 foreach ( string rule in excludeRule )
292292 {
293- Regex excludeRegex = new Regex ( rule . Replace ( " *", ".*?" ) , RegexOptions . IgnoreCase ) ;
293+ Regex excludeRegex = new Regex ( String . Format ( "^{0}$" , Regex . Escape ( rule ) . Replace ( @"\ *", ".*" ) ) , RegexOptions . IgnoreCase ) ;
294294 excludeRegexList . Add ( excludeRegex ) ;
295295 }
296296 }
@@ -361,8 +361,7 @@ private void AnalyzeFile(string filePath)
361361 break ;
362362 }
363363 }
364- if ( ( includeRule == null || includeRule . Contains ( scriptRule . GetName ( ) , StringComparer . OrdinalIgnoreCase ) || includeRegexMatch ) &&
365- ( excludeRule == null || ! excludeRule . Contains ( scriptRule . GetName ( ) , StringComparer . OrdinalIgnoreCase ) || ! excludeRegexMatch ) )
364+ if ( ( includeRule == null || includeRegexMatch ) && ( excludeRule == null || ! excludeRegexMatch ) )
366365 {
367366 WriteVerbose ( string . Format ( CultureInfo . CurrentCulture , Strings . VerboseRunningMessage , scriptRule . GetName ( ) ) ) ;
368367
@@ -435,10 +434,9 @@ private void AnalyzeFile(string filePath)
435434 {
436435 excludeRegexMatch = true ;
437436 break ;
438- }
437+ }
439438 }
440- if ( ( includeRule == null || includeRule . Contains ( commandRule . GetName ( ) , StringComparer . OrdinalIgnoreCase ) || includeRegexMatch ) &&
441- ( excludeRule == null || ! excludeRule . Contains ( commandRule . GetName ( ) , StringComparer . OrdinalIgnoreCase ) || ! excludeRegexMatch ) )
439+ if ( ( includeRule == null || includeRegexMatch ) && ( excludeRule == null || ! excludeRegexMatch ) )
442440 {
443441 foreach ( KeyValuePair < CommandInfo , IScriptExtent > commandInfo in cmdInfoTable )
444442 {
@@ -485,8 +483,7 @@ private void AnalyzeFile(string filePath)
485483 break ;
486484 }
487485 }
488- if ( ( includeRule == null || includeRule . Contains ( tokenRule . GetName ( ) , StringComparer . OrdinalIgnoreCase ) || includeRegexMatch ) &&
489- ( excludeRule == null || ! excludeRule . Contains ( tokenRule . GetName ( ) , StringComparer . OrdinalIgnoreCase ) ) || ! excludeRegexMatch )
486+ if ( ( includeRule == null || includeRegexMatch ) && ( excludeRule == null || ! excludeRegexMatch ) )
490487 {
491488 WriteVerbose ( string . Format ( CultureInfo . CurrentCulture , Strings . VerboseRunningMessage , tokenRule . GetName ( ) ) ) ;
492489
@@ -530,8 +527,7 @@ private void AnalyzeFile(string filePath)
530527 break ;
531528 }
532529 }
533- if ( ( includeRule == null || includeRule . Contains ( dscResourceRule . GetName ( ) , StringComparer . OrdinalIgnoreCase ) || includeRegexMatch ) &&
534- ( excludeRule == null || ! excludeRule . Contains ( dscResourceRule . GetName ( ) , StringComparer . OrdinalIgnoreCase ) || excludeRegexMatch ) )
530+ if ( ( includeRule == null || includeRegexMatch ) && ( excludeRule == null || excludeRegexMatch ) )
535531 {
536532 WriteVerbose ( string . Format ( CultureInfo . CurrentCulture , Strings . VerboseRunningMessage , dscResourceRule . GetName ( ) ) ) ;
537533
@@ -588,8 +584,7 @@ private void AnalyzeFile(string filePath)
588584 excludeRegexMatch = true ;
589585 }
590586 }
591- if ( ( includeRule == null || includeRule . Contains ( dscResourceRule . GetName ( ) , StringComparer . OrdinalIgnoreCase ) || includeRegexMatch ) &&
592- ( excludeRule == null || ! excludeRule . Contains ( dscResourceRule . GetName ( ) , StringComparer . OrdinalIgnoreCase ) || ! excludeRegexMatch ) )
587+ if ( ( includeRule == null || includeRegexMatch ) && ( excludeRule == null || ! excludeRegexMatch ) )
593588 {
594589 WriteVerbose ( string . Format ( CultureInfo . CurrentCulture , Strings . VerboseRunningMessage , dscResourceRule . GetName ( ) ) ) ;
595590
0 commit comments