Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions changes-entries/includes-error.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*) mod_include: Don't print any of if/elsif/else content when
a conditional evaluation returns an error. [Eric Covener]
22 changes: 22 additions & 0 deletions modules/filters/mod_include.c
Original file line number Diff line number Diff line change
Expand Up @@ -2329,6 +2329,8 @@ static apr_status_t handle_if(include_ctx_t *ctx, ap_filter_t *f,

if (ctx->argc != 1) {
SSI_CREATE_ERROR_BUCKET(ctx, f, bb);
ctx->flags &= SSI_FLAG_CLEAR_PRINT_COND;
ctx->flags |= SSI_FLAG_COND_ERROR;
return APR_SUCCESS;
}

Expand All @@ -2338,13 +2340,17 @@ static apr_status_t handle_if(include_ctx_t *ctx, ap_filter_t *f,
ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(01354) "unknown parameter \"%s\" "
"to tag if in %s", tag, r->filename);
SSI_CREATE_ERROR_BUCKET(ctx, f, bb);
ctx->flags &= SSI_FLAG_CLEAR_PRINT_COND;
ctx->flags |= SSI_FLAG_COND_ERROR;
return APR_SUCCESS;
}

if (!expr) {
ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(01355) "missing expr value for if "
"element in %s", r->filename);
SSI_CREATE_ERROR_BUCKET(ctx, f, bb);
ctx->flags &= SSI_FLAG_CLEAR_PRINT_COND;
ctx->flags |= SSI_FLAG_COND_ERROR;
return APR_SUCCESS;
}

Expand All @@ -2356,6 +2362,8 @@ static apr_status_t handle_if(include_ctx_t *ctx, ap_filter_t *f,
expr_ret = parse_ap_expr(ctx, expr, &was_error);

if (was_error) {
ctx->flags &= SSI_FLAG_CLEAR_PRINT_COND;
ctx->flags |= SSI_FLAG_COND_ERROR;
SSI_CREATE_ERROR_BUCKET(ctx, f, bb);
return APR_SUCCESS;
}
Expand Down Expand Up @@ -2401,6 +2409,8 @@ static apr_status_t handle_elif(include_ctx_t *ctx, ap_filter_t *f,

if (ctx->argc != 1) {
SSI_CREATE_ERROR_BUCKET(ctx, f, bb);
ctx->flags &= SSI_FLAG_CLEAR_PRINT_COND;
ctx->flags |= SSI_FLAG_COND_ERROR;
return APR_SUCCESS;
}

Expand All @@ -2410,13 +2420,17 @@ static apr_status_t handle_elif(include_ctx_t *ctx, ap_filter_t *f,
ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(01358) "unknown parameter \"%s\" "
"to tag if in %s", tag, r->filename);
SSI_CREATE_ERROR_BUCKET(ctx, f, bb);
ctx->flags &= SSI_FLAG_CLEAR_PRINT_COND;
ctx->flags |= SSI_FLAG_COND_ERROR;
return APR_SUCCESS;
}

if (!expr) {
ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(01359) "missing expr in elif "
"statement: %s", r->filename);
SSI_CREATE_ERROR_BUCKET(ctx, f, bb);
ctx->flags &= SSI_FLAG_CLEAR_PRINT_COND;
ctx->flags |= SSI_FLAG_COND_ERROR;
return APR_SUCCESS;
}

Expand All @@ -2434,6 +2448,8 @@ static apr_status_t handle_elif(include_ctx_t *ctx, ap_filter_t *f,
expr_ret = parse_ap_expr(ctx, expr, &was_error);

if (was_error) {
ctx->flags &= SSI_FLAG_CLEAR_PRINT_COND;
ctx->flags |= SSI_FLAG_COND_ERROR;
SSI_CREATE_ERROR_BUCKET(ctx, f, bb);
return APR_SUCCESS;
}
Expand Down Expand Up @@ -2480,6 +2496,11 @@ static apr_status_t handle_else(include_ctx_t *ctx, ap_filter_t *f,

DEBUG_DUMP_COND(ctx, " else");

/* Don't toggle printing if there was an expression evaluation error */
if (ctx->flags & SSI_FLAG_COND_ERROR) {
return APR_SUCCESS;
}

if (ctx->flags & SSI_FLAG_COND_TRUE) {
ctx->flags &= SSI_FLAG_CLEAR_PRINTING;
}
Expand Down Expand Up @@ -2519,6 +2540,7 @@ static apr_status_t handle_endif(include_ctx_t *ctx, ap_filter_t *f,
DEBUG_DUMP_COND(ctx, "endif");

ctx->flags |= (SSI_FLAG_PRINTING | SSI_FLAG_COND_TRUE);
ctx->flags &= ~SSI_FLAG_COND_ERROR;

return APR_SUCCESS;
}
Expand Down
1 change: 1 addition & 0 deletions modules/filters/mod_include.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
#define SSI_FLAG_COND_TRUE (1<<1) /* Conditional eval'd to true. */
#define SSI_FLAG_SIZE_IN_BYTES (1<<2) /* Sizes displayed in bytes. */
#define SSI_FLAG_NO_EXEC (1<<3) /* No Exec in current context. */
#define SSI_FLAG_COND_ERROR (1<<4) /* Conditional evaluation was in error */

#define SSI_FLAG_SIZE_ABBREV (~(SSI_FLAG_SIZE_IN_BYTES))
#define SSI_FLAG_CLEAR_PRINT_COND (~((SSI_FLAG_PRINTING) | \
Expand Down
Loading