diff options
author | Gluzskiy Alexandr <sss@sss.chaoslab.ru> | 2012-02-11 14:12:04 +0200 |
---|---|---|
committer | Gluzskiy Alexandr <sss@sss.chaoslab.ru> | 2012-02-11 14:12:04 +0200 |
commit | 1abe0e83270a64e2a51e7c2cbb66b76bc406a5a0 (patch) | |
tree | 93726a63efb78dc9d205234d2fdb2b40f5e842d7 | |
parent | 3dff6b71bb4ea90129d9b9721cb862a85c696fc4 (diff) |
fix possible export key problem
-rwxr-xr-x | main.cpp | 21 |
1 files changed, 18 insertions, 3 deletions
@@ -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; |