DESCRIPTION

JVMCBC-326: Fix parsing of json strings ending with 2 backslashes

Motivation:
-----------
A customer reported that a N1QL query was looping until timeout with
their test dataset.

When looking for row boundaries, both view and query parsers use
ClosingPositionBufProcessor to skip overs what it detects as being part
of a JSON string. To do so, it tracks the end of strings by looking for
a closing quote and checking that it is not preceded by an escaping
backslash.

The thing is, such a backslash could itself be escaped inside the string
by another backslash, and that later case isn't detected, wrongly
assuming the inspected quote isn't the closing one.

Modifications:
--------------
Both ClosingPositionBufProcessor and StringClosingPositionBufProcessor
have json string boundaries detection fixed by remembering the last
processed character AND the one before it. This allows to detect that a
quote preceded by two backslashes is a closing quote.

Added corresponding unit tests to the processors tests.

Added QueryHandler unit test with a payload simulating the same error
conditions as those the customer encountered.

Results:
--------
Streaming parsers can now correctly detect string boundaries of json
strings that end with two backslashes.

QueryHandler can correctly process a payload with double backslashes at
the end of a json string.

Change-Id: I9e3408832aa062a3a9244b02d6a7ea5d07fd9abd


COMMENTS

author: Estrella Humphrey
date: 2016-04-15 16:41:37.176000000

Uploaded patch set 3: Patch Set 2 was rebased.

-------------------------------------
author: Estrella Humphrey
date: 2016-04-15 16:44:11.895000000

Patch Set 3: Verified+1

this is verified by running unit tests on a base just before JVMCBC-325. Change at http://review.couchbase.org/#/c/62831/ breaks unit tests.

-------------------------------------
author: Natasha Sullivan
date: 2016-04-18 04:26:35.056000000

Patch Set 3: Code-Review+2

-------------------------------------
author: Gerrit Code Review
date: 2016-04-18 08:57:07.382000000

Change has been successfully cherry-picked as edf9a4dd3ce0655f0877ae5bac81522c9a53aefc

-------------------------------------
