| Index: pkg/front_end/lib/src/fasta/quote.dart
|
| diff --git a/pkg/front_end/lib/src/fasta/quote.dart b/pkg/front_end/lib/src/fasta/quote.dart
|
| index 8d9525304f1d57a467dabc86573914029cafcecf..a0624144952c7ac9f67c17a7aacb6dad5b94138d 100644
|
| --- a/pkg/front_end/lib/src/fasta/quote.dart
|
| +++ b/pkg/front_end/lib/src/fasta/quote.dart
|
| @@ -68,7 +68,7 @@ int lengthOfOptionalWhitespacePrefix(String first, int start) {
|
| }
|
| if (code == $TAB || code == $SPACE) continue;
|
| if (code == $CR) {
|
| - if (i + 1 < codeUnits.length && codeUnits[i] == $LF) {
|
| + if (i + 1 < codeUnits.length && codeUnits[i + 1] == $LF) {
|
| i++;
|
| }
|
| return i + 1;
|
| @@ -140,17 +140,27 @@ String unescape(String string, Quote quote) {
|
| switch (quote) {
|
| case Quote.Single:
|
| case Quote.Double:
|
| + return !string.contains("\\")
|
| + ? string
|
| + : unescapeCodeUnits(string.codeUnits, false);
|
| +
|
| case Quote.MultiLineSingle:
|
| case Quote.MultiLineDouble:
|
| - break;
|
| + return !string.contains("\\") && !string.contains("\r")
|
| + ? string
|
| + : unescapeCodeUnits(string.codeUnits, false);
|
|
|
| case Quote.RawSingle:
|
| case Quote.RawDouble:
|
| + return string;
|
| +
|
| case Quote.RawMultiLineSingle:
|
| case Quote.RawMultiLineDouble:
|
| - return string;
|
| + return !string.contains("\r")
|
| + ? string
|
| + : unescapeCodeUnits(string.codeUnits, true);
|
| }
|
| - return !string.contains("\\") ? string : unescapeCodeUnits(string.codeUnits);
|
| + return internalError("Unhandled string quote: $quote");
|
| }
|
|
|
| const String incompleteSequence = "Incomplete escape sequence.";
|
| @@ -161,7 +171,7 @@ const String invalidCodePoint = "Invalid code point.";
|
|
|
| // Note: based on
|
| // [StringValidator.validateString](pkg/compiler/lib/src/string_validator.dart).
|
| -String unescapeCodeUnits(List<int> codeUnits) {
|
| +String unescapeCodeUnits(List<int> codeUnits, bool isRaw) {
|
| // Can't use Uint8List or Uint16List here, the code units may be larger.
|
| List<int> result = new List<int>(codeUnits.length);
|
| int resultOffset = 0;
|
| @@ -171,7 +181,12 @@ String unescapeCodeUnits(List<int> codeUnits) {
|
|
|
| for (int i = 0; i < codeUnits.length; i++) {
|
| int code = codeUnits[i];
|
| - if (code == $BACKSLASH) {
|
| + if (code == $CR) {
|
| + if (i + 1 < codeUnits.length && codeUnits[i + 1] == $LF) {
|
| + i++;
|
| + }
|
| + code = $LF;
|
| + } else if (!isRaw && code == $BACKSLASH) {
|
| if (codeUnits.length == ++i) return error(i, incompleteSequence);
|
| code = codeUnits[i];
|
|
|
|
|