Fix escaped backslash crash (#1870)

* Fix escaped backslash crash

Fixes #1855.

* Code review
This commit is contained in:
Jennifer Thakar 2023-01-24 16:03:49 -08:00 committed by GitHub
parent 0248608c44
commit 00069241b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 1 deletions

View File

@ -14,6 +14,8 @@
* Produce a better error message for a nested property whose name starts with * Produce a better error message for a nested property whose name starts with
`--`. `--`.
* Fix a crash when a selector ends in an escaped backslash.
## 1.57.1 ## 1.57.1
* No user-visible changes. * No user-visible changes.

View File

@ -114,7 +114,7 @@ int? _lastNonWhitespace(String string, {bool excludeEscape = false}) {
if (!isWhitespace(codeUnit)) { if (!isWhitespace(codeUnit)) {
if (excludeEscape && if (excludeEscape &&
i != 0 && i != 0 &&
i != string.length && i != string.length - 1 &&
codeUnit == $backslash) { codeUnit == $backslash) {
return i + 1; return i + 1;
} else { } else {