ngx_escape_json: fixes missing len increment for non escapable json chars when dst NULL

Valentin V. Bartenev vbart at nginx.com
Sat Apr 1 16:30:51 UTC 2017


On Saturday 01 April 2017 16:50:35 Paulo Pacheco wrote:
> # HG changeset patch
> # User Paulo Pacheco <fooinha at gmail.com>
> # Date 1491061541 0
> #      Sat Apr 01 15:45:41 2017 +0000
> # Node ID bc97af7bf9eb3def877f5ebaecf4fd8a277108d0
> # Parent  28dc369899ea77b03fab44d8878b273d28f06437
> ngx_string: fixes len increment for non escapable json chars
> 
> diff -r 28dc369899ea -r bc97af7bf9eb src/core/ngx_string.c
> --- a/src/core/ngx_string.c Sun Mar 26 01:25:01 2017 -0700
> +++ b/src/core/ngx_string.c Sat Apr 01 15:45:41 2017 +0000
> @@ -1811,6 +1811,8 @@
>                  len += sizeof("\\u001F") - 2;
>              }
> 
> +            len++;
> +
>              size--;
>          }
> 
> 
[..]

The function counts additional escape chars, not normal one.  If it returns 
zero, then no escaping needed.

  wbr, Valentin V. Bartenev



More information about the nginx-devel mailing list