| 605 |
* The choice of returning NULL strings on not-found, |
* The choice of returning NULL strings on not-found, |
| 606 |
* v.s. empty strings on an empty match is deliberate. |
* v.s. empty strings on an empty match is deliberate. |
| 607 |
*/ |
*/ |
| 608 |
if (!re) { |
if (!re || !re->have_match) { |
| 609 |
ap_log_rerror(APLOG_MARK, APLOG_WARNING, 0, r, |
ap_log_rerror(APLOG_MARK, APLOG_WARNING, 0, r, |
| 610 |
"regex capture $%" APR_SIZE_T_FMT " refers to no regex in %s", |
"regex capture $%" APR_SIZE_T_FMT " refers to no regex in %s", |
| 611 |
idx, r->filename); |
idx, r->filename); |
| 612 |
return NULL; |
return NULL; |
| 613 |
} |
} |
| 614 |
else { |
else if (re->match[idx]rm_so == re->match[idx].rm_eo) { |
| 615 |
if (re->nsub < idx || idx >= AP_MAX_REG_MATCH) { |
return NULL; |
| 616 |
|
} |
| 617 |
|
else if (re->match[idx].rm_so < 0 || re->match[idx].rm_eo < 0) { |
| 618 |
|
/* I don't think this can happen if have_match is true. |
| 619 |
|
* But let's not risk a regression by dropping this |
| 620 |
|
*/ |
| 621 |
|
return NULL; |
| 622 |
|
} |
| 623 |
|
else if (re->nsub < idx || idx >= AP_MAX_REG_MATCH) { |
| 624 |
ap_log_rerror(APLOG_MARK, APLOG_WARNING, 0, r, |
ap_log_rerror(APLOG_MARK, APLOG_WARNING, 0, r, |
| 625 |
"regex capture $%" APR_SIZE_T_FMT |
"regex capture $%" APR_SIZE_T_FMT |
| 626 |
" is out of range (last regex was: '%s') in %s", |
" is out of range (last regex was: '%s') in %s", |
| 628 |
return NULL; |
return NULL; |
| 629 |
} |
} |
| 630 |
|
|
| 631 |
if (re->match[idx].rm_so < 0 || re->match[idx].rm_eo < 0) { |
else { |
|
return NULL; |
|
|
} |
|
|
|
|
| 632 |
val = apr_pstrmemdup(ctx->dpool, re->source + re->match[idx].rm_so, |
val = apr_pstrmemdup(ctx->dpool, re->source + re->match[idx].rm_so, |
| 633 |
re->match[idx].rm_eo - re->match[idx].rm_so); |
re->match[idx].rm_eo - re->match[idx].rm_so); |
| 634 |
} |
} |