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

Unified Diff: pkg/compiler/lib/src/string_validator.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
« no previous file with comments | « no previous file | pkg/front_end/lib/src/fasta/quote.dart » ('j') | pkg/front_end/lib/src/fasta/quote.dart » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/string_validator.dart
diff --git a/pkg/compiler/lib/src/string_validator.dart b/pkg/compiler/lib/src/string_validator.dart
index 75f59f54a81352479f999f2239cc5b80834047fb..208353a52f5d666390dfe573a025c2df782a4445 100644
--- a/pkg/compiler/lib/src/string_validator.dart
+++ b/pkg/compiler/lib/src/string_validator.dart
@@ -25,7 +25,13 @@ class StringValidator {
int leftQuote = 0;
int rightQuote = 0;
if (isFirst) leftQuote = quoting.leftQuoteLength;
- if (isLast) rightQuote = quoting.rightQuoteLength;
+ if (isLast) {
+ // Check for unterminated string
+ if (leftQuote < source.length &&
+ source[source.length - 1] == quoting.quoteChar) {
+ rightQuote = quoting.rightQuoteLength;
ahe 2017/05/29 15:05:30 What happens with this string: """x"
+ }
+ }
String content = copyWithoutQuotes(source, leftQuote, rightQuote);
return validateString(
token, token.charOffset + leftQuote, content, quoting);
« no previous file with comments | « no previous file | pkg/front_end/lib/src/fasta/quote.dart » ('j') | pkg/front_end/lib/src/fasta/quote.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698