dgaudet 98/02/23 02:53:35
Modified: src CHANGES
src/modules/standard mod_setenvif.c
Log:
BrowserMatch didn't handle spaces in the regex properly. I redid Ronald's
patch because it would have required proper quoting to work right.
While I was in there I removed the need for the cmd->info cast, and cleaned
up a few other things.
PR: 1825
Submitted by: Ronald Tschalaer <[EMAIL PROTECTED]>
Revision Changes Path
1.661 +3 -0 apache-1.3/src/CHANGES
Index: CHANGES
===================================================================
RCS file: /export/home/cvs/apache-1.3/src/CHANGES,v
retrieving revision 1.660
retrieving revision 1.661
diff -u -r1.660 -r1.661
--- CHANGES 1998/02/23 08:34:56 1.660
+++ CHANGES 1998/02/23 10:53:27 1.661
@@ -1,5 +1,8 @@
Changes with Apache 1.3b6
+ *) The mod_setenvif BrowserMatch backwards compatibility command did not
+ work properly with spaces in the regex. [Ronald Tschalaer] PR#1825
+
*) Add new RewriteMap types: First, `rnd' which is equivalent to the `txt'
type but with a special post-processing for the looked-up value: It
parses it into alternatives according to `|' chars and then only one
1.16 +35 -35 apache-1.3/src/modules/standard/mod_setenvif.c
Index: mod_setenvif.c
===================================================================
RCS file: /export/home/cvs/apache-1.3/src/modules/standard/mod_setenvif.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- mod_setenvif.c 1998/01/31 15:34:50 1.15
+++ mod_setenvif.c 1998/02/23 10:53:31 1.16
@@ -146,35 +146,27 @@
return a;
}
-static const char *add_setenvif(cmd_parms *cmd, void *mconfig, const char
*args)
+/* any non-NULL magic constant will do... used to indicate if REG_ICASE
should be
+ * used */
+#define ICASE_MAGIC ((void *)(&setenvif_module))
+
+static const char *add_setenvif_core(cmd_parms *cmd, void *mconfig,
+ char *fname, const char *args)
{
- char *fname;
char *regex;
const char *feature;
- const char *cmdline = args;
sei_cfg_rec *sconf = get_module_config(cmd->server->module_config,
&setenvif_module);
sei_entry *new, *entries = (sei_entry *) sconf->conditionals->elts;
char *var;
int i;
- int cflags = (int) (long) cmd->info;
- char *error;
int beenhere = 0;
- /*
- * Pull in the invariant pieces from the command line.
- */
- fname = getword_conf(cmd->pool, &cmdline);
- if (!*fname) {
- error = pstrcat(cmd->pool, "Missing header-field name for ",
- cmd->cmd->name, NULL);
- return error;
- }
- regex = getword_conf(cmd->pool, &cmdline);
+ /* get regex */
+ regex = getword_conf(cmd->pool, &args);
if (!*regex) {
- error = pstrcat(cmd->pool, "Missing regular expression for ",
+ return pstrcat(cmd->pool, "Missing regular expression for ",
cmd->cmd->name, NULL);
- return error;
}
/*
@@ -195,17 +187,17 @@
new->name = fname;
new->regex = regex;
new->preg = pregcomp(cmd->pool, regex,
- (REG_EXTENDED | REG_NOSUB | cflags));
+ (REG_EXTENDED | REG_NOSUB
+ | (cmd->info == ICASE_MAGIC ? REG_ICASE : 0)));
if (new->preg == NULL) {
- error = pstrcat(cmd->pool, cmd->cmd->name,
+ return pstrcat(cmd->pool, cmd->cmd->name,
" regex could not be compiled.", NULL);
- return error;
}
new->features = make_table(cmd->pool, 5);
gotit:
for( ; ; ) {
- feature = getword_conf(cmd->pool, &cmdline);
+ feature = getword_conf(cmd->pool, &args);
if(!*feature)
break;
beenhere++;
@@ -223,38 +215,46 @@
}
if (!beenhere) {
- error = pstrcat(cmd->pool, "Missing envariable expression for ",
+ return pstrcat(cmd->pool, "Missing envariable expression for ",
cmd->cmd->name, NULL);
- return error;
}
return NULL;
}
+static const char *add_setenvif(cmd_parms *cmd, void *mconfig, const char
*args)
+{
+ char *fname;
+
+ /* get header name */
+ fname = getword_conf(cmd->pool, &args);
+ if (!*fname) {
+ return pstrcat(cmd->pool, "Missing header-field name for ",
+ cmd->cmd->name, NULL);
+ }
+ return add_setenvif_core(cmd, mconfig, fname, args);
+}
+
/*
* This routine handles the BrowserMatch* directives. It simply turns around
* and feeds them, with the appropriate embellishments, to the
general-purpose
* command handler.
*/
-static const char *add_browser(cmd_parms *cmd, void *mconfig, char *word1,
- char *word2)
+static const char *add_browser(cmd_parms *cmd, void *mconfig, const char
*args)
{
- const char *match_command;
-
- match_command = pstrcat(cmd->pool, "User-Agent ", word1, " ", word2,
NULL);
- return add_setenvif(cmd, mconfig, match_command);
+ return add_setenvif_core(cmd, mconfig, "User-Agent", args);
}
static command_rec setenvif_module_cmds[] =
{
- {"SetEnvIf", add_setenvif, (void *) 0,
+ {"SetEnvIf", add_setenvif, NULL,
RSRC_CONF, RAW_ARGS, "A header-name, regex and a list of variables."},
- {"SetEnvIfNoCase", add_setenvif, (void *) REG_ICASE,
+ {"SetEnvIfNoCase", add_setenvif, ICASE_MAGIC,
RSRC_CONF, RAW_ARGS, "a header-name, regex and a list of variables."},
- {"BrowserMatch", add_browser, (void *) 0,
- RSRC_CONF, ITERATE2, "A browser regex and a list of variables."},
- {"BrowserMatchNoCase", add_browser, (void *) REG_ICASE,
- RSRC_CONF, ITERATE2, "A browser regex and a list of variables."},
+ {"BrowserMatch", add_browser, NULL,
+ RSRC_CONF, RAW_ARGS, "A browser regex and a list of variables."},
+ {"BrowserMatchNoCase", add_browser, ICASE_MAGIC,
+ RSRC_CONF, RAW_ARGS, "A browser regex and a list of variables."},
{NULL},
};