View | Details | Raw Unified | Return to bug 54543
Collapse All | Expand All

(-)httpd-2.4.3/modules/mappers/mod_rewrite.c (-6 / +36 lines)
Lines 166-171 Link Here
166
#define RULEFLAG_DISCARDPATHINFO    1<<15
166
#define RULEFLAG_DISCARDPATHINFO    1<<15
167
#define RULEFLAG_QSDISCARD          1<<16
167
#define RULEFLAG_QSDISCARD          1<<16
168
#define RULEFLAG_END                1<<17
168
#define RULEFLAG_END                1<<17
169
#define RULEFLAG_NOPRECOMPILE       1<<18
169
170
170
/* return code of the rewrite rule
171
/* return code of the rewrite rule
171
 * the result may be escaped - or not
172
 * the result may be escaped - or not
Lines 3334-3340 Link Here
3334
            return apr_pstrcat(cmd->pool, "RewriteCond: cannot compile regular "
3335
            return apr_pstrcat(cmd->pool, "RewriteCond: cannot compile regular "
3335
                               "expression '", a2, "'", NULL);
3336
                               "expression '", a2, "'", NULL);
3336
        }
3337
        }
3337
3338
        newcond->regexp  = regexp;
3338
        newcond->regexp  = regexp;
3339
    }
3339
    }
3340
    else if (newcond->ptype == CONDPAT_AP_EXPR) {
3340
    else if (newcond->ptype == CONDPAT_AP_EXPR) {
Lines 3483-3488 Link Here
3483
            || !strcasecmp(key, "ocase")) {                /* nocase */
3483
            || !strcasecmp(key, "ocase")) {                /* nocase */
3484
            cfg->flags |= RULEFLAG_NOCASE;
3484
            cfg->flags |= RULEFLAG_NOCASE;
3485
        }
3485
        }
3486
        else if (!strcasecmp(key, "pc")) {                 /* npc */
3487
            cfg->flags |= RULEFLAG_NOPRECOMPILE;
3488
        }
3489
3486
        else {
3490
        else {
3487
            ++error;
3491
            ++error;
3488
        }
3492
        }
Lines 3640-3653 Link Here
3640
        ++a1;
3644
        ++a1;
3641
    }
3645
    }
3642
3646
3643
    regexp = ap_pregcomp(cmd->pool, a1, AP_REG_EXTENDED |
3647
    /* avoid precompiling */
3648
    if (cmd->path && (newrule->flags & RULEFLAG_NOPRECOMPILE)) {
3649
        regexp = NULL;
3650
        }
3651
    else {
3652
        regexp = ap_pregcomp(cmd->pool, a1, AP_REG_EXTENDED |
3644
                                        ((newrule->flags & RULEFLAG_NOCASE)
3653
                                        ((newrule->flags & RULEFLAG_NOCASE)
3645
                                         ? AP_REG_ICASE : 0));
3654
                                         ? AP_REG_ICASE : 0));
3646
    if (!regexp) {
3655
        if (!regexp) {
3647
        return apr_pstrcat(cmd->pool,
3656
             return apr_pstrcat(cmd->pool,
3648
                           "RewriteRule: cannot compile regular expression '",
3657
                           "RewriteRule: cannot compile regular expression '",
3649
                           a1, "'", NULL);
3658
                           a1, "'", NULL);
3650
    }
3659
             }
3660
       }
3651
3661
3652
    newrule->pattern = a1;
3662
    newrule->pattern = a1;
3653
    newrule->regexp  = regexp;
3663
    newrule->regexp  = regexp;
Lines 3923-3928 Link Here
3923
    char *newuri = NULL;
3933
    char *newuri = NULL;
3924
    request_rec *r = ctx->r;
3934
    request_rec *r = ctx->r;
3925
    int is_proxyreq = 0;
3935
    int is_proxyreq = 0;
3936
    ap_regex_t *regexp;
3926
3937
3927
    ctx->uri = r->filename;
3938
    ctx->uri = r->filename;
3928
3939
Lines 3956-3968 Link Here
3956
        }
3967
        }
3957
    }
3968
    }
3958
3969
3970
    /* Compile regex if not already compiled
3971
     */
3972
    regexp = p->regexp;
3973
3974
    if (!regexp) {
3975
	rewritelog((r, 4, ctx->perdir, "RewriteRule: compiling pattern='%s' %s",
3976
                p->pattern, (p->flags & CONDFLAG_NOCASE) ? " [NC]" : ""));
3977
3978
        regexp = ap_pregcomp(r->pool, p->pattern,
3979
                             AP_REG_EXTENDED | ((p->flags & CONDFLAG_NOCASE)
3980
                                             ? AP_REG_ICASE : 0));
3981
        if (!regexp) {
3982
            ap_log_error(APLOG_MARK, APLOG_ERR, 0, NULL,
3983
                        "RewriteRule: cannot compile regular expression '%s'",
3984
                        p->pattern);
3985
            return 0;
3986
        }
3987
    }
3988
3959
    /* Try to match the URI against the RewriteRule pattern
3989
    /* Try to match the URI against the RewriteRule pattern
3960
     * and exit immediately if it didn't apply.
3990
     * and exit immediately if it didn't apply.
3961
     */
3991
     */
3962
    rewritelog((r, 3, ctx->perdir, "applying pattern '%s' to uri '%s'",
3992
    rewritelog((r, 3, ctx->perdir, "applying pattern '%s' to uri '%s'",
3963
                p->pattern, ctx->uri));
3993
                p->pattern, ctx->uri));
3964
3994
3965
    rc = !ap_regexec(p->regexp, ctx->uri, AP_MAX_REG_MATCH, regmatch, 0);
3995
    rc = !ap_regexec(regexp, ctx->uri, AP_MAX_REG_MATCH, regmatch, 0);
3966
    if (! (( rc && !(p->flags & RULEFLAG_NOTMATCH)) ||
3996
    if (! (( rc && !(p->flags & RULEFLAG_NOTMATCH)) ||
3967
           (!rc &&  (p->flags & RULEFLAG_NOTMATCH))   ) ) {
3997
           (!rc &&  (p->flags & RULEFLAG_NOTMATCH))   ) ) {
3968
        return 0;
3998
        return 0;

Return to bug 54543