summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2023-09-07 13:09:37 +0300
committerGeorge Hazan <george.hazan@gmail.com>2023-09-07 13:09:37 +0300
commit1c0337dabc5a5fe2c6391411be7537928bb7779b (patch)
treea8729c7526845e91a6119e2820a4c8f5ff58baeb
parent1f02b06d272c67249537b0f812eeb7b32fd0bea1 (diff)
fixes #3668 (cyrillic letters are allowed in the internal account names)
-rw-r--r--src/mir_app/src/proto_opts.cpp26
1 files changed, 17 insertions, 9 deletions
diff --git a/src/mir_app/src/proto_opts.cpp b/src/mir_app/src/proto_opts.cpp
index 06f2eee4a6..fa1ebf12e7 100644
--- a/src/mir_app/src/proto_opts.cpp
+++ b/src/mir_app/src/proto_opts.cpp
@@ -859,18 +859,26 @@ bool CAccountFormDlg::OnInitDialog()
bool CAccountFormDlg::OnApply()
{
- wchar_t tszAccName[256];
- m_accName.GetText(tszAccName, _countof(tszAccName));
- rtrimw(tszAccName);
- if (tszAccName[0] == 0) {
+ wchar_t wszAccName[256];
+ m_accName.GetText(wszAccName, _countof(wszAccName));
+ rtrimw(wszAccName);
+ if (wszAccName[0] == 0) {
MessageBoxW(m_hwnd, TranslateT("Account name must be filled."), TranslateT("Account error"), MB_ICONERROR | MB_OK);
return false;
}
if (m_action == PRAC_ADDED) {
- char buf[200];
- m_internalName.GetTextA(buf, _countof(buf));
- if (FindAccountByName(rtrim(buf))) {
+ wchar_t buf[200];
+ m_internalName.GetText(buf, _countof(buf));
+ rtrimw(buf);
+
+ for (auto *p = buf; *p; p++)
+ if (*p < 32 || *p > 127) {
+ MessageBoxW(m_hwnd, TranslateT("Account name contains invalid symbols, only ASCII chars are allowed."), TranslateT("Account error"), MB_ICONERROR | MB_OK);
+ return false;
+ }
+
+ if (FindAccountByName(_T2A(buf))) {
MessageBoxW(m_hwnd, TranslateT("Account name has to be unique. Please enter unique name."), TranslateT("Account error"), MB_ICONERROR | MB_OK);
return false;
}
@@ -899,10 +907,10 @@ bool CAccountFormDlg::OnApply()
m_internalName.GetTextA(buf, _countof(buf));
rtrim(buf);
- m_pa = Proto_CreateAccount(buf, szBaseProto, tszAccName);
+ m_pa = Proto_CreateAccount(buf, szBaseProto, wszAccName);
}
else {
- replaceStrW(m_pa->tszAccountName, tszAccName);
+ replaceStrW(m_pa->tszAccountName, wszAccName);
WriteDbAccounts();
NotifyEventHooks(hAccListChanged, m_action, (LPARAM)m_pa);