@@ -97,31 +97,29 @@ public static bool IsValidExpression(string expression)
9797 /// <returns>True if the expression is valid, false otherwise.</returns>
9898 public static bool IsValidFilterExpression ( string toTest )
9999 {
100- if ( toTest == null ) {
101- throw new ArgumentNullException ( "toTest" ) ;
102- }
103-
104100 bool result = true ;
105101
106102 try {
107- string [ ] items = SplitQuoted ( toTest ) ;
108- for ( int i = 0 ; i < items . Length ; ++ i ) {
109- if ( ( items [ i ] != null ) && ( items [ i ] . Length > 0 ) ) {
110- string toCompile ;
103+ if ( toTest != null ) {
104+ string [ ] items = SplitQuoted ( toTest ) ;
105+ for ( int i = 0 ; i < items . Length ; ++ i ) {
106+ if ( ( items [ i ] != null ) && ( items [ i ] . Length > 0 ) ) {
107+ string toCompile ;
111108
112- if ( items [ i ] [ 0 ] == '+' ) {
113- toCompile = items [ i ] . Substring ( 1 , items [ i ] . Length - 1 ) ;
114- }
115- else if ( items [ i ] [ 0 ] == '-' ) {
116- toCompile = items [ i ] . Substring ( 1 , items [ i ] . Length - 1 ) ;
117- }
118- else {
119- toCompile = items [ i ] ;
120- }
109+ if ( items [ i ] [ 0 ] == '+' ) {
110+ toCompile = items [ i ] . Substring ( 1 , items [ i ] . Length - 1 ) ;
111+ }
112+ else if ( items [ i ] [ 0 ] == '-' ) {
113+ toCompile = items [ i ] . Substring ( 1 , items [ i ] . Length - 1 ) ;
114+ }
115+ else {
116+ toCompile = items [ i ] ;
117+ }
121118
122- Regex testRegex = new Regex ( toCompile , RegexOptions . IgnoreCase | RegexOptions . Singleline ) ;
123- }
124- }
119+ Regex testRegex = new Regex ( toCompile , RegexOptions . IgnoreCase | RegexOptions . Singleline ) ;
120+ }
121+ }
122+ }
125123 }
126124 catch ( ArgumentException ) {
127125 result = false ;
0 commit comments