From 1abe0e83270a64e2a51e7c2cbb66b76bc406a5a0 Mon Sep 17 00:00:00 2001 From: Gluzskiy Alexandr Date: Sat, 11 Feb 2012 14:12:04 +0200 Subject: fix possible export key problem --- main.cpp | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'main.cpp') diff --git a/main.cpp b/main.cpp index 913ecbf..c5a8847 100755 --- a/main.cpp +++ b/main.cpp @@ -1568,10 +1568,25 @@ static BOOL CALLBACK DlgProcLoadExistingKey(HWND hwndDlg,UINT msg,WPARAM wParam, { out.erase(s, 1); } - TCHAR *tmp = mir_a2t(out.c_str()); + std::string::size_type p1 = 0, p2 = 0; + p1 = out.find("-----BEGIN PGP PUBLIC KEY BLOCK-----"); + if(p1 != std::string::npos) + { + p2 = out.find("-----END PGP PUBLIC KEY BLOCK-----", p1); + if(p2 != std::string::npos) + { + p2 += strlen("-----END PGP PUBLIC KEY BLOCK-----"); + out = out.substr(p1, p2-p1); + TCHAR *tmp = mir_a2t(out.c_str()); + SetWindowText(hPubKeyEdit, tmp); + mir_free(tmp); + } + else + MessageBoxA(NULL, Translate("Failed to export public key."), Translate("Error"), MB_OK); + } + else + MessageBoxA(NULL, Translate("Failed to export public key."), Translate("Error"), MB_OK); // SetDlgItemText(hPubKeyEdit, IDC_PUBLIC_KEY_EDIT, tmp); - SetWindowText(hPubKeyEdit, tmp); - mir_free(tmp); } DestroyWindow(hwndDlg); break; -- cgit v1.2.3