cue/literal: allow triple quotes inside multiline string content
The spec says that a multiline string is closed by a matching triple
quote "which must be by itself on a new line, preceded by optional
whitespace". The scanner already enforces this rule, only treating
triple quotes as a closing delimiter when they follow a newline
and optional whitespace.
However, literal.Unquote rejected any triple quote sequence found
in the middle of the string content, even when it clearly wasn't
a closing delimiter (e.g. preceded by non-whitespace characters).
For example, the following valid multiline string was rejected:
"""
0"""
"""
Fix unquoteChar to treat triple quotes as literal quote characters
when they appear in the middle of multiline string content, matching
the scanner's behavior and the spec's grammar.
Found via fuzzing.
Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
Change-Id: I116a1528680cc9b750dec37de2e278f9fb3ec2ab
Reviewed-on: https://cue.gerrithub.io/c/cue-lang/cue/+/1235173
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
Reviewed-by: Matthew Sackman <matthew@cue.works>