thanks for finding this problem in the queryparser. I attach a patch file that fixes this bug. Now the queryparser does not recognize an escaped quote inside a phrase as the phrase terminator anymore.
I also updated the testcase org.apache.lucene.queryParser.TestQueryParser to test escaped quotes within phrases. This testcase fails with the old version of the queryparser and runs successful with the patched version. I added the following three tests to the testEscaped() method:
(1) assertQueryEquals("a \\\"b c\\\" d", a, "a \"b c\" d");
+b c d\"", a, "\"a
+b c d\"");
(3) assertQueryEquals("\"a \\\"b c\\\" d\"", a, "\"a \\\"b c\\\" d\"");
Please notice that (3) is different from your second suggested assert. You assume that the queryparser unescapes the quotes inside the phrase, but the queryparser does not unescape any escaped characters inside a phrase. You can see that in (2), where the escaped + (plus) character does not become unescaped.