Image filter: configuration inheritance fixes.

The image_filter_jpeg_quality, image_filter_sharpen and "image_filter rotate"
were inherited incorrectly if a directive with variables was defined, and
then redefined to a literal value, i.e. in configurations like

    image_filter_jpeg_quality $arg_q;

    location / {
        image_filter_jpeg_quality 50;
    }

Patch by Ian Babrou, with minor changes.
This commit is contained in:
Maxim Dounin 2012-12-20 19:04:28 +00:00
parent f4b9d89103
commit 717acb74a7

View File

@ -1200,22 +1200,30 @@ ngx_http_image_filter_merge_conf(ngx_conf_t *cf, void *parent, void *child)
}
}
/* 75 is libjpeg default quality */
ngx_conf_merge_uint_value(conf->jpeg_quality, prev->jpeg_quality, 75);
if (conf->jpeg_quality == NGX_CONF_UNSET_UINT) {
if (conf->jqcv == NULL) {
conf->jqcv = prev->jqcv;
/* 75 is libjpeg default quality */
ngx_conf_merge_uint_value(conf->jpeg_quality, prev->jpeg_quality, 75);
if (conf->jqcv == NULL) {
conf->jqcv = prev->jqcv;
}
}
ngx_conf_merge_uint_value(conf->sharpen, prev->sharpen, 0);
if (conf->sharpen == NGX_CONF_UNSET_UINT) {
ngx_conf_merge_uint_value(conf->sharpen, prev->sharpen, 0);
if (conf->shcv == NULL) {
conf->shcv = prev->shcv;
if (conf->shcv == NULL) {
conf->shcv = prev->shcv;
}
}
ngx_conf_merge_uint_value(conf->angle, prev->angle, 0);
if (conf->acv == NULL) {
conf->acv = prev->acv;
if (conf->angle == NGX_CONF_UNSET_UINT) {
ngx_conf_merge_uint_value(conf->angle, prev->angle, 0);
if (conf->acv == NULL) {
conf->acv = prev->acv;
}
}
ngx_conf_merge_value(conf->transparency, prev->transparency, 1);