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

Unified Diff: sdk/lib/io/string_stream.dart

Issue 11364115: Don't crash when decoding astral plane UTF-8. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 1 month 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 | tests/standalone/io/string_stream_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/io/string_stream.dart
diff --git a/sdk/lib/io/string_stream.dart b/sdk/lib/io/string_stream.dart
index 5d71af4245e6d1ff65f953000a9e87ffcad1c5d6..41b31bfee48e7673e03357581cbd0779b3ef6874 100644
--- a/sdk/lib/io/string_stream.dart
+++ b/sdk/lib/io/string_stream.dart
@@ -88,19 +88,18 @@ abstract class _StringDecoderBase implements _StringDecoder {
String decoded([int len]) {
if (isEmpty) return null;
- String result;
+ List<int> result;
if (len !== null && len < available()) {
- result = new String.fromCharCodes(_result.getRange(_resultOffset, len));
+ result = _result.getRange(_resultOffset, len);
} else {
Mads Ager (google) 2012/11/07 06:54:40 Let's change this to if (len !== null && len < av
Bob Nystrom 2012/11/07 17:28:05 Done.
if (_resultOffset == 0) {
- result = new String.fromCharCodes(_result);
+ result = _result;
} else {
- result =
- new String.fromCharCodes(
- _result.getRange(_resultOffset,
- _result.length - _resultOffset));
+ result = _result.getRange(_resultOffset,
+ _result.length - _resultOffset);
}
}
+
_resultOffset += result.length;
while (!_lineBreakEnds.isEmpty &&
_lineBreakEnds.first < _charOffset + _resultOffset) {
@@ -108,7 +107,7 @@ abstract class _StringDecoderBase implements _StringDecoder {
_lineBreaks--;
}
if (_result.length == _resultOffset) _resetResult();
- return result;
+ return new String.fromCharCodes(result);
}
String get decodedLine {
@@ -419,7 +418,7 @@ class _StringInputStream implements StringInputStream {
void set onError(void callback(e)) {
_input.onError = callback;
- _decoder.onError = (e) {
+ _decoder.onError = (e) {
_clientCloseHandler = null;
_input.close();
callback(e);
« no previous file with comments | « no previous file | tests/standalone/io/string_stream_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698