mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-16 14:17:12 +02:00
Validate quick reply name.
This commit is contained in:
parent
288979d8e7
commit
9483d17fc8
1 changed files with 17 additions and 1 deletions
|
@ -162,6 +162,22 @@ void QuickReplies::setupContent(
|
|||
Ui::ResizeFitChild(this, content);
|
||||
}
|
||||
|
||||
[[nodiscard]] bool ValidShortcutName(const QString &name) {
|
||||
if (name.isEmpty() || name.size() > 32) {
|
||||
return false;
|
||||
}
|
||||
for (const auto &ch : name) {
|
||||
if (!ch.isLetterOrNumber()
|
||||
&& (ch != '_')
|
||||
&& (ch != 0x200c)
|
||||
&& (ch != 0x00b7)
|
||||
&& (ch < 0x0d80 || ch > 0x0dff)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
Type QuickRepliesId() {
|
||||
|
@ -195,7 +211,7 @@ void EditShortcutNameBox(
|
|||
|
||||
const auto callback = [=] {
|
||||
const auto name = field->getLastText().trimmed();
|
||||
if (name.isEmpty()) {
|
||||
if (!ValidShortcutName(name)) {
|
||||
field->showError();
|
||||
} else {
|
||||
submit(name, [weak = Ui::MakeWeak(box)] {
|
||||
|
|
Loading…
Add table
Reference in a new issue