return NULL;
}
else if (re->match[idx].rm_so < 0 || re->match[idx].rm_eo < 0) {
- /* I don't think this can happen if have_match is true.
- * But let's not risk a regression by dropping this
- */
+ /* This particular subpattern was not used by the regex */
return NULL;
}
-
else {
val = apr_pstrmemdup(ctx->dpool, re->source + re->match[idx].rm_so,
re->match[idx].rm_eo - re->match[idx].rm_so);
/* fallback regex for ls -s1; ($0..$2) == 3 */
#define LS_REG_PATTERN "^ *([0-9]+) +([^ ]+)$"
#define LS_REG_MATCH 3
+ap_regex_t *ls_regex = NULL;
static apr_status_t proxy_send_dir_filter(ap_filter_t *f,
apr_bucket_brigade *in)
char *filename;
int found = 0;
int eos = 0;
-
- ap_regex_t *re = NULL;
ap_regmatch_t re_result[LS_REG_MATCH];
- /* Compile the output format of "ls -s1" as a fallback for non-unix ftp listings */
- re = ap_pregcomp(p, LS_REG_PATTERN, AP_REG_EXTENDED);
- ap_assert(re != NULL);
-
/* get a complete line */
/* if the buffer overruns - throw data away */
while (!found && !APR_BRIGADE_EMPTY(ctx->in)) {
}
}
/* Try a fallback for listings in the format of "ls -s1" */
- else if (0 == ap_regexec(re, ctx->buffer, LS_REG_MATCH, re_result, 0)) {
-
+ else if (0 == ap_regexec(ls_regex, ctx->buffer, LS_REG_MATCH, re_result, 0)) {
+ /*
+ * We don't need to check for rm_eo == rm_so == -1 here since ls_regex
+ * is such that $2 cannot be unset if we have a match.
+ */
filename = apr_pstrndup(p, &ctx->buffer[re_result[2].rm_so], re_result[2].rm_eo - re_result[2].rm_so);
str = apr_pstrcat(p, ap_escape_html(p, apr_pstrndup(p, ctx->buffer, re_result[2].rm_so)),
/* filters */
ap_register_output_filter("PROXY_SEND_DIR", proxy_send_dir_filter,
NULL, AP_FTYPE_RESOURCE);
+ /* Compile the output format of "ls -s1" as a fallback for non-unix ftp listings */
+ ls_regex = ap_pregcomp(p, LS_REG_PATTERN, AP_REG_EXTENDED);
+ ap_assert(ls_regex != NULL);
}
static const command_rec proxy_ftp_cmds[] =
ap_expr_eval_ctx_t ctx;
int dont_vary = (info->flags & AP_EXPR_FLAG_DONT_VARY);
const char *tmp_source = NULL, *vary_this = NULL;
- ap_regmatch_t tmp_pmatch[10];
+ ap_regmatch_t tmp_pmatch[AP_MAX_REG_MATCH];
AP_DEBUG_ASSERT((info->flags & AP_EXPR_FLAG_STRING_RESULT) == 0);
ctx.data = NULL;
if (!pmatch) {
- ctx.re_nmatch = 10;
+ ctx.re_nmatch = AP_MAX_REG_MATCH;
ctx.re_pmatch = tmp_pmatch;
ctx.re_source = &tmp_source;
}
ap_expr_eval_ctx_t ctx;
int dont_vary, rc;
const char *tmp_source = NULL, *vary_this = NULL;
- ap_regmatch_t tmp_pmatch[10];
+ ap_regmatch_t tmp_pmatch[AP_MAX_REG_MATCH];
const char *result;
AP_DEBUG_ASSERT(info->flags & AP_EXPR_FLAG_STRING_RESULT);
ctx.result_string = &result;
if (!pmatch) {
- ctx.re_nmatch = 10;
+ ctx.re_nmatch = AP_MAX_REG_MATCH;
ctx.re_pmatch = tmp_pmatch;
ctx.re_source = &tmp_source;
}