Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(21)

Unified Diff: pkg/front_end/lib/src/fasta/quote.dart

Issue 2912693002: improve fasta unterminated string recovery (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 a0624144952c7ac9f67c17a7aacb6dad5b94138d..3d9c60375a0e1c0d84241414d17a1d824de13387 100644
--- a/pkg/front_end/lib/src/fasta/quote.dart
+++ b/pkg/front_end/lib/src/fasta/quote.dart
@@ -130,10 +130,12 @@ String unescapeLastStringPart(String last, Quote quote) {
String unescapeString(String string) {
Quote quote = analyzeQuote(string);
- return unescape(
- string.substring(firstQuoteLength(string, quote),
- string.length - lastQuoteLength(quote)),
- quote);
+ int startIndex = firstQuoteLength(string, quote);
+ if (startIndex == string.length) {
+ return '';
+ }
+ int endIndex = string.length - lastQuoteLength(quote);
+ return unescape(string.substring(startIndex, endIndex), quote);
ahe 2017/05/29 15:05:30 Same question.
}
String unescape(String string, Quote quote) {

Powered by Google App Engine
This is Rietveld 408576698