Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions lib/core/security/ssl_certificate_support.dart
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,21 @@ Future<String?> resolveMongoTlsCertificateKeyFile({
final merged = File('${dir.path}/client.pem');
await merged.writeAsString('$certBytes\n$keyBytes\n', flush: true);
if (!Platform.isWindows) {
// `Process.run` does not throw on a non-zero exit, so check it: a key
// file that stayed at the default mode must not be handed out silently.
try {
await Process.run('chmod', ['600', merged.path]);
} catch (_) {}
final result = await Process.run('chmod', ['600', merged.path]);
if (result.exitCode != 0) {
throw FileSystemException(
'Could not restrict permissions of the TLS client key file: '
'${result.stderr}'.trim(),
merged.path,
);
}
} catch (_) {
await cleanupMongoTlsTempFile(merged.path);
rethrow;
}
}
return merged.path;
}
Expand Down
9 changes: 5 additions & 4 deletions lib/core/storage/local_db.dart
Original file line number Diff line number Diff line change
Expand Up @@ -583,8 +583,9 @@ class LocalDb {
[kMutationAuditCap],
);
}
} catch (_) {
// Best effort.
} catch (e) {
// Best effort, but a missing audit trail should not be invisible.
debugPrint('LocalDb: could not record a mutation audit entry: $e');
}
}

Expand Down Expand Up @@ -624,8 +625,8 @@ class LocalDb {
'SELECT id FROM mcp_activity ORDER BY id DESC LIMIT 1 OFFSET ?)',
[kMcpActivityCap],
);
} catch (_) {
// Best effort.
} catch (e) {
debugPrint('LocalDb: could not record MCP activity: $e');
}
}

Expand Down
37 changes: 25 additions & 12 deletions lib/features/workspace/grid_cell_popover_inspector.dart
Original file line number Diff line number Diff line change
Expand Up @@ -169,26 +169,39 @@ class _GridCellInspectorDialogState
});
}

bool _isJson() {
final text = _controller.text.trim();
// build() asks for both on every rebuild. Parsing a large cell each time
// janks, so the answer is kept for the text it was computed for (the
// controller hands out the same String until the text changes).
String? _kindText;
var _kindIsJson = false;
var _kindIsXml = false;

void _refreshKind() {
final raw = _controller.text;
if (identical(raw, _kindText)) return;
_kindText = raw;
final text = raw.trim();
_kindIsJson = false;
_kindIsXml = false;
if ((text.startsWith('{') && text.endsWith('}')) ||
(text.startsWith('[') && text.endsWith(']'))) {
try {
jsonDecode(text);
return true;
} catch (_) {
return false;
}
_kindIsJson = true;
} catch (_) {}
} else if (text.startsWith('<') && text.endsWith('>')) {
_kindIsXml = XmlHtmlFormatter.validate(text) == null;
}
return false;
}

bool _isJson() {
_refreshKind();
return _kindIsJson;
}

bool _isXml() {
final text = _controller.text.trim();
if (text.startsWith('<') && text.endsWith('>')) {
return XmlHtmlFormatter.validate(text) == null;
}
return false;
_refreshKind();
return _kindIsXml;
}

bool _isHex() {
Expand Down
Loading