]> granicus.if.org Git - apache/commitdiff
Fix SetEnvIfExpr to work with expressions that do not set the regexp
authorStefan Fritsch <sf@apache.org>
Sun, 28 Nov 2010 13:01:59 +0000 (13:01 +0000)
committerStefan Fritsch <sf@apache.org>
Sun, 28 Nov 2010 13:01:59 +0000 (13:01 +0000)
reference data.
Add some trace logging.

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

modules/metadata/mod_setenvif.c

index 5a3cac272072e7da6a2731375c5995212566c6ce..9676603fa562d8ac04f165d0b7790c1e0a679d15 100644 (file)
@@ -637,16 +637,19 @@ static int match_headers(request_rec *r)
                 val_len = val ? strlen(val) : 0;
             }
 
-            /*
-             * A NULL value indicates that the header field or special entity
-             * wasn't present or is undefined.  Represent that as an empty string
-             * so that REs like "^$" will work and allow envariable setting
-             * based on missing or empty field.
-             */
-            if (val == NULL) {
-                val = "";
-                val_len = 0;
-            }
+        }
+
+        /*
+         * A NULL value indicates that the header field or special entity
+         * wasn't present or is undefined.  Represent that as an empty string
+         * so that REs like "^$" will work and allow envariable setting
+         * based on missing or empty field. This is also necessary to make
+         * ap_pregsub work after evaluating an ap_expr which does set the
+         * regexp backref data.
+         */
+        if (val == NULL) {
+            val = "";
+            val_len = 0;
         }
 
         if ((b->pattern && apr_strmatch(b->pattern, val, val_len)) ||
@@ -675,6 +678,12 @@ static int match_headers(request_rec *r)
                     }
                 }
             }
+            if (APLOGrtrace2(r)) {
+                ap_log_rerror(APLOG_MARK, APLOG_TRACE2, 0, r,
+                              "Setting envvar(s): %s",
+                              apr_array_pstrcat(r->pool, arr, ' '));
+
+            }
         }
     }