]> granicus.if.org Git - apache/commitdiff
hrm. reverting my last commit. TOKEN_GROUP is a protection against many
authorAndré Malo <nd@apache.org>
Wed, 27 Aug 2003 20:26:28 +0000 (20:26 +0000)
committerAndré Malo <nd@apache.org>
Wed, 27 Aug 2003 20:26:28 +0000 (20:26 +0000)
invalid expressions. Checking these all manually would take a lot more
cycles than it'd save. Sorry.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@101115 13f79535-47bb-0310-9956-ffa450edef68

modules/filters/mod_include.c

index 2b1b3a3ada4007978d4ee27e8c23df4ee909f23a..c923101f4b90264a248cb95e99e28e6f3db882b2 100644 (file)
@@ -126,6 +126,7 @@ typedef enum {
     TOKEN_NE,
     TOKEN_RBRACE,
     TOKEN_LBRACE,
+    TOKEN_GROUP,
     TOKEN_GE,
     TOKEN_LE,
     TOKEN_GT,
@@ -335,6 +336,7 @@ static void debug_dump_tree(include_ctx_t *ctx, parse_node_t *root)
             continue;
 
         case TOKEN_NOT:
+        case TOKEN_GROUP:
         case TOKEN_RBRACE:
         case TOKEN_LBRACE:
             if (!current->dump_done) {
@@ -1211,7 +1213,8 @@ static int parse_expr(include_ctx_t *ctx, const char *expr, int *was_error)
                 break;
 
             case TOKEN_RE:
-            case TOKEN_RBRACE: /* cannot happen */
+            case TOKEN_RBRACE:
+            case TOKEN_GROUP:
                 ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
                               "Invalid expression \"%s\" in file %s",
                               expr, r->filename);
@@ -1330,23 +1333,7 @@ static int parse_expr(include_ctx_t *ctx, const char *expr, int *was_error)
                 return retval;
             }
 
-            /* empty groups return TRUE (backwards compat) */
-            if (!current->right) {
-                CREATE_NODE(ctx, current->right);
-                TYPE_TOKEN(&current->right->token, TOKEN_STRING);
-                current->right->token.value = "()";
-            }
-
-            current->right->parent = current->parent;
-            if (!current->parent) {
-                current = root = current->right;
-            }
-            else if (current->parent->left == current) {
-                current = current->parent->left = current->right;
-            }
-            else {
-                current = current->parent->right = current->right;
-            }
+            TYPE_TOKEN(&current->token, TOKEN_GROUP);
             break;
 
         case TOKEN_NOT:
@@ -1354,7 +1341,8 @@ static int parse_expr(include_ctx_t *ctx, const char *expr, int *was_error)
             switch (current->token.type) {
             case TOKEN_STRING:
             case TOKEN_RE:
-            case TOKEN_RBRACE: /* cannot happen */
+            case TOKEN_RBRACE:
+            case TOKEN_GROUP:
                 ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
                               "Invalid expression \"%s\" in file %s",
                               expr, r->filename);
@@ -1369,6 +1357,9 @@ static int parse_expr(include_ctx_t *ctx, const char *expr, int *was_error)
             new->parent = current;
             current = new;
             break;
+
+        default:
+            break;
         }
     }
 
@@ -1569,6 +1560,23 @@ static int parse_expr(include_ctx_t *ctx, const char *expr, int *was_error)
             current = current->parent;
             break;
 
+        case TOKEN_GROUP:
+            if (current->right) {
+                if (!current->right->done) {
+                    current = current->right;
+                    continue;
+                }
+                current->value = current->right->value;
+            }
+            else {
+                current->value = 1;
+            }
+
+            DEBUG_DUMP_EVAL(ctx, current);
+            current->done = 1;
+            current = current->parent;
+            break;
+
         case TOKEN_LBRACE:
             ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
                           "Unmatched '(' in \"%s\" in file %s",