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

Side by Side Diff: sdk/lib/io/platform_impl.dart

Issue 2273053002: Ignore non-UTF8 strings in the environment (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 3 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 unified diff | Download patch
« no previous file with comments | « runtime/bin/platform.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 part of dart.io; 5 part of dart.io;
6 6
7 class _Platform { 7 class _Platform {
8 external static int _numberOfProcessors(); 8 external static int _numberOfProcessors();
9 external static String _pathSeparator(); 9 external static String _pathSeparator();
10 external static String _operatingSystem(); 10 external static String _operatingSystem();
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 59
60 static Map<String, String> get environment { 60 static Map<String, String> get environment {
61 if (_environmentCache == null) { 61 if (_environmentCache == null) {
62 var env = _environment(); 62 var env = _environment();
63 if (env is !OSError) { 63 if (env is !OSError) {
64 var isWindows = operatingSystem == 'windows'; 64 var isWindows = operatingSystem == 'windows';
65 var result = isWindows 65 var result = isWindows
66 ? new _CaseInsensitiveStringMap<String>() 66 ? new _CaseInsensitiveStringMap<String>()
67 : new Map<String, String>(); 67 : new Map<String, String>();
68 for (var str in env) { 68 for (var str in env) {
69 if (str == null) {
70 continue;
71 }
69 // The Strings returned by [_environment()] are expected to be 72 // The Strings returned by [_environment()] are expected to be
70 // valid environment entries, but exceptions have been seen 73 // valid environment entries, but exceptions have been seen
71 // (e.g., an entry of just '=' has been seen on OS/X). 74 // (e.g., an entry of just '=' has been seen on OS/X).
72 // Invalid entries (lines without a '=' or with an empty name) 75 // Invalid entries (lines without a '=' or with an empty name)
73 // are discarded. 76 // are discarded.
74 var equalsIndex = str.indexOf('='); 77 var equalsIndex = str.indexOf('=');
75 if (equalsIndex > 0) { 78 if (equalsIndex > 0) {
76 result[str.substring(0, equalsIndex)] = 79 result[str.substring(0, equalsIndex)] =
77 str.substring(equalsIndex + 1); 80 str.substring(equalsIndex + 1);
78 } 81 }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 V remove(Object key) => key is String ? _map.remove(key.toUpperCase()) : null; 117 V remove(Object key) => key is String ? _map.remove(key.toUpperCase()) : null;
115 void clear() { _map.clear(); } 118 void clear() { _map.clear(); }
116 void forEach(void f(String key, V value)) { _map.forEach(f); } 119 void forEach(void f(String key, V value)) { _map.forEach(f); }
117 Iterable<String> get keys => _map.keys; 120 Iterable<String> get keys => _map.keys;
118 Iterable<V> get values => _map.values; 121 Iterable<V> get values => _map.values;
119 int get length => _map.length; 122 int get length => _map.length;
120 bool get isEmpty => _map.isEmpty; 123 bool get isEmpty => _map.isEmpty;
121 bool get isNotEmpty => _map.isNotEmpty; 124 bool get isNotEmpty => _map.isNotEmpty;
122 String toString() => _map.toString(); 125 String toString() => _map.toString();
123 } 126 }
OLDNEW
« no previous file with comments | « runtime/bin/platform.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698