MCPcopy Create free account
hub / github.com/apache/httpd / cmd_rewritecond

Function cmd_rewritecond

modules/mappers/mod_rewrite.c:3519–3694  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3517}
3518
3519static const char *cmd_rewritecond(cmd_parms *cmd, void *in_dconf,
3520 const char *in_str)
3521{
3522 rewrite_perdir_conf *dconf = in_dconf;
3523 char *str = apr_pstrdup(cmd->pool, in_str);
3524 rewrite_server_conf *sconf;
3525 rewritecond_entry *newcond;
3526 ap_regex_t *regexp;
3527 char *a1 = NULL, *a2 = NULL, *a2_end, *a3 = NULL;
3528 const char *err;
3529
3530 sconf = ap_get_module_config(cmd->server->module_config, &rewrite_module);
3531
3532 /* make a new entry in the internal temporary rewrite rule list */
3533 if (cmd->path == NULL) { /* is server command */
3534 newcond = apr_array_push(sconf->rewriteconds);
3535 }
3536 else { /* is per-directory command */
3537 newcond = apr_array_push(dconf->rewriteconds);
3538 }
3539
3540 /* parse the argument line ourself
3541 * a1 .. a3 are substrings of str, which is a fresh copy
3542 * of the argument line. So we can use a1 .. a3 without
3543 * copying them again.
3544 */
3545 if (parseargline(str, &a1, &a2, &a2_end, &a3)) {
3546 return apr_pstrcat(cmd->pool, "RewriteCond: bad argument line '", str,
3547 "'", NULL);
3548 }
3549
3550 /* arg1: the input string */
3551 newcond->input = a1;
3552
3553 /* arg3: optional flags field
3554 * (this has to be parsed first, because we need to
3555 * know if the regex should be compiled with ICASE!)
3556 */
3557 newcond->flags = CONDFLAG_NONE;
3558 if (a3 != NULL) {
3559 if ((err = cmd_parseflagfield(cmd->pool, newcond, a3,
3560 cmd_rewritecond_setflag)) != NULL) {
3561 return apr_pstrcat(cmd->pool, "RewriteCond: ", err, NULL);
3562 }
3563 }
3564
3565 /* arg2: the pattern */
3566 newcond->pattern = a2;
3567 if (*a2 == '!') {
3568 newcond->flags |= CONDFLAG_NOTMATCH;
3569 ++a2;
3570 }
3571
3572 /* determine the pattern type */
3573 newcond->ptype = CONDPAT_REGEX;
3574 if (strcasecmp(a1, "expr") == 0) {
3575 newcond->ptype = CONDPAT_AP_EXPR;
3576 }

Callers

nothing calls this directly

Calls 5

ap_get_module_configFunction · 0.85
parsearglineFunction · 0.85
cmd_parseflagfieldFunction · 0.85
ap_pregcompFunction · 0.85
ap_log_errorFunction · 0.50

Tested by

no test coverage detected