@@ -986,38 +986,44 @@ msre_action *msre_create_action(msre_engine *engine, apr_pool_t *mp, const char
986986 return action ;
987987}
988988
989- // Return 1 if "name=value" is present in table (for supplied action)
989+ /**
990+ * Helper function for action_exists. It checks if "name=value" is present in table for supplied action.
991+ */
990992static int apr_table_action_exists (apr_pool_t * p , const apr_table_t * vartable , const char * action , const char * name , const char * value ) {
991- if (strcmp (name , action ) != 0 ) return 0 ;
993+ if (strcmp (name , action ) != 0 ) return 0 ;
994+
995+ const char * vars = apr_table_getm (p , vartable , name );
996+ if (!vars ) return 0 ;
992997
993- const char * vars = apr_table_getm ( p , vartable , name ) ;
994- if (! vars ) return 0 ;
998+ char pattern [ 200 ] ;
999+ sprintf ( pattern , "(?:^|,)%.185s(?:,|$)" , value ) ;
9951000
996- char pattern [200 ];
997- sprintf (pattern , "(?:^|,)%.185s(?:,|$)" , value );
1001+ char * error_msg = NULL ;
1002+ msc_regex_t * regex = msc_pregcomp (p , pattern , 0 , NULL , NULL );
1003+ if (regex == NULL ) return 0 ; // we could log an error here
9981004
999- const char * errptr = NULL ;
1000- int erroffset ;
1001- const pcre * regex = pcre_compile (pattern , 0 , & errptr , & erroffset , NULL );
1002- return !pcre_exec (regex , NULL , vars , strlen (vars ), 0 , 0 , 0 , 0 );
1005+ return (msc_regexec (regex , vars , strlen (vars ), & error_msg ) >= 0 );
10031006}
10041007
1005- // Return 1 if "name=value" is present in table for tags, logdata (and others)
1008+ /**
1009+ * Checks if "name=value" is present in table for tags, logdata (and others).
1010+ */
10061011static int action_exists (apr_pool_t * p , const apr_table_t * vartable , const char * name , const char * value ) {
1007- if (apr_table_action_exists (p , vartable , "capture" , name , value )) return 1 ;
1008- if (apr_table_action_exists (p , vartable , "chain" , name , value )) return 1 ;
1009- if (apr_table_action_exists (p , vartable , "initcol" , name , value )) return 1 ;
1010- if (apr_table_action_exists (p , vartable , "logdata" , name , value )) return 1 ;
1011- if (apr_table_action_exists (p , vartable , "multiMatch" , name , value )) return 1 ;
1012- if (apr_table_action_exists (p , vartable , "sanitiseArg" , name , value )) return 1 ;
1013- if (apr_table_action_exists (p , vartable , "sanitiseMatched" , name , value )) return 1 ;
1014- if (apr_table_action_exists (p , vartable , "sanitiseMatchedBytes" , name , value )) return 1 ;
1015- if (apr_table_action_exists (p , vartable , "sanitiseRequestHeader" , name , value )) return 1 ;
1016- if (apr_table_action_exists (p , vartable , "sanitiseResponseHeader" , name , value )) return 1 ;
1017- if (apr_table_action_exists (p , vartable , "setrsc" , name , value )) return 1 ;
1018- if (apr_table_action_exists (p , vartable , "setsid" , name , value )) return 1 ;
1019- if (apr_table_action_exists (p , vartable , "setuid" , name , value )) return 1 ;
1020- if (apr_table_action_exists (p , vartable , "tag" , name , value )) return 1 ;
1012+ /* logdata & msg cannot be used because ',' is used as entries separators */
1013+ if (apr_table_action_exists (p , vartable , "capture" , name , value )) return 1 ;
1014+ if (apr_table_action_exists (p , vartable , "chain" , name , value )) return 1 ;
1015+ if (apr_table_action_exists (p , vartable , "initcol" , name , value )) return 1 ;
1016+ if (apr_table_action_exists (p , vartable , "multiMatch" , name , value )) return 1 ;
1017+ if (apr_table_action_exists (p , vartable , "phase" , name , value )) return 1 ;
1018+ if (apr_table_action_exists (p , vartable , "sanitizeArg" , name , value )) return 1 ;
1019+ if (apr_table_action_exists (p , vartable , "sanitizeMatched" , name , value )) return 1 ;
1020+ if (apr_table_action_exists (p , vartable , "sanitizeMatchedBytes" , name , value )) return 1 ;
1021+ if (apr_table_action_exists (p , vartable , "sanitizeRequestHeader" , name , value )) return 1 ;
1022+ if (apr_table_action_exists (p , vartable , "sanitizeResponseHeader" , name , value )) return 1 ;
1023+ if (apr_table_action_exists (p , vartable , "setrsc" , name , value )) return 1 ;
1024+ if (apr_table_action_exists (p , vartable , "setsid" , name , value )) return 1 ;
1025+ if (apr_table_action_exists (p , vartable , "setuid" , name , value )) return 1 ;
1026+ if (apr_table_action_exists (p , vartable , "tag" , name , value )) return 1 ;
10211027 return 0 ;
10221028}
10231029
0 commit comments