mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-17 07:14:28 +01:00
Fix "PEM header must end with -----" by standardizing CRLF
This commit is contained in:
@@ -118,12 +118,16 @@ class _PrivateKeyEditPageState extends State<PrivateKeyEditPage> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String _standardizeLineSeparators(String value) {
|
||||||
|
return value.replaceAll("\r\n", "\n").replaceAll("\r", "\n");
|
||||||
|
}
|
||||||
|
|
||||||
Widget _buildFAB() {
|
Widget _buildFAB() {
|
||||||
return FloatingActionButton(
|
return FloatingActionButton(
|
||||||
tooltip: l10n.save,
|
tooltip: l10n.save,
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
final name = _nameController.text;
|
final name = _nameController.text;
|
||||||
final key = _keyController.text.trim();
|
final key = _standardizeLineSeparators(_keyController.text.trim());
|
||||||
final pwd = _pwdController.text;
|
final pwd = _pwdController.text;
|
||||||
if (name.isEmpty || key.isEmpty) {
|
if (name.isEmpty || key.isEmpty) {
|
||||||
context.showSnackBar(l10n.fieldMustNotEmpty);
|
context.showSnackBar(l10n.fieldMustNotEmpty);
|
||||||
@@ -201,11 +205,8 @@ class _PrivateKeyEditPageState extends State<PrivateKeyEditPage> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final content = await file.readAsString();
|
final content = await file.readAsString();
|
||||||
|
// dartssh2 accepts only LF (but not CRLF or CR)
|
||||||
/// Issue #7
|
_keyController.text = _standardizeLineSeparators(content.trim());
|
||||||
/// Replace all CRLF to LF
|
|
||||||
content.replaceAll('\r\n', '\n');
|
|
||||||
_keyController.text = content;
|
|
||||||
},
|
},
|
||||||
child: Text(l10n.pickFile),
|
child: Text(l10n.pickFile),
|
||||||
),
|
),
|
||||||
|
|||||||
Reference in New Issue
Block a user