Add tests for some odd escaping behavior in the CONF parser

Honestly, these are probably bugs, but add tests for them so, if we
change the behavior, we do so intentionally. The escape processing logic
has checks for hitting the end of the string early.

At first, I had a hard time reaching this case because this is normally
processed as a line continuation. However, the line continuation logic
is not escape-aware. It just assumes if your line ends "...\\\\", that
the last backslash is not a continuation. I.e. it doesn't correctly
count escapes.

This is almost certainly a bug, but means the escape + EOF behavior is
reachable. Even more interesting is that it seems to intentionally
terminate quote handling. Add tests for these cases.

Change-Id: I9e058ec2b1ce3e20d87eab28a64c79880e3e5cae
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/68288
Reviewed-by: Bob Beck <bbe@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
diff --git a/crypto/conf/conf_test.cc b/crypto/conf/conf_test.cc
index 4905cb3..53b9648 100644
--- a/crypto/conf/conf_test.cc
+++ b/crypto/conf/conf_test.cc
@@ -363,6 +363,43 @@
               {"default", {{"key", "\xe2\x98\x83"}}},
           },
       },
+
+      // An escaped backslash is not a line continuation.
+      {
+          R"(
+key1 = value1\\
+key2 = value2
+)",
+          {
+              {"default", {{"key1", "value1\\"}, {"key2", "value2"}}},
+          },
+      },
+
+      // An unterminated escape sequence at the end of a line is silently
+      // ignored. Normally, this would be a line continuation, but the line
+      // continuation logic does not count backslashes and only looks at the
+      // last two characters. This is probably a bug.
+      {
+          R"(
+key1 = value1\\\
+key2 = value2
+)",
+          {
+              {"default", {{"key1", "value1\\"}, {"key2", "value2"}}},
+          },
+      },
+
+      // The above also happens inside a quoted string, even allowing the quoted
+      // string to be unterminated. This is also probably a bug.
+      {
+          R"(
+key1 = "value1\\\
+key2 = value2
+)",
+          {
+              {"default", {{"key1", "value1\\"}, {"key2", "value2"}}},
+          },
+      },
   };
   for (const auto &t : kTests) {
     SCOPED_TRACE(t.in);