Initialize Android physical interfaces and preserve macOS scoped routes. Add redacted diagnostics, default DNS, ordered auto-save, simplified controls, scanner rotation settings, and native regression coverage. Restore vendored build sources and document validation and stability checks.
45 lines
1.2 KiB
Dart
45 lines
1.2 KiB
Dart
/// Keeps known credentials for the whole session, including replaced drafts.
|
|
class DiagnosticRedactor {
|
|
final _secrets = <String>{};
|
|
|
|
void remember(Object? value, {String? key}) {
|
|
if (value is Map) {
|
|
for (final entry in value.entries) {
|
|
remember(entry.value, key: '${entry.key}');
|
|
}
|
|
} else if (value is Iterable) {
|
|
for (final item in value) {
|
|
remember(item, key: key);
|
|
}
|
|
} else if (value is String &&
|
|
value.isNotEmpty &&
|
|
{
|
|
'password',
|
|
'username',
|
|
'uuid',
|
|
'network_secret',
|
|
'token',
|
|
'private_key',
|
|
}.contains(key)) {
|
|
_secrets.add(value);
|
|
}
|
|
}
|
|
|
|
String sanitize(String text) {
|
|
final secrets = _secrets.toList()
|
|
..sort((a, b) => b.length.compareTo(a.length));
|
|
for (final value in secrets) {
|
|
text = text.replaceAll(value, '[已隐藏]');
|
|
}
|
|
text = text.replaceAllMapped(
|
|
RegExp(r'([a-zA-Z][a-zA-Z0-9+.-]*://)[^\s/]+@'),
|
|
(m) => '${m[1]}[已隐藏]@',
|
|
);
|
|
text = text.replaceAllMapped(
|
|
RegExp(r'([a-zA-Z][a-zA-Z0-9+.-]*://[^\s?]+)\?[^\s]+'),
|
|
(m) => '${m[1]}?[已隐藏]',
|
|
);
|
|
return text;
|
|
}
|
|
}
|