mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +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);
|
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
|
} // namespace
|
||||||
|
|
||||||
Type QuickRepliesId() {
|
Type QuickRepliesId() {
|
||||||
|
@ -195,7 +211,7 @@ void EditShortcutNameBox(
|
||||||
|
|
||||||
const auto callback = [=] {
|
const auto callback = [=] {
|
||||||
const auto name = field->getLastText().trimmed();
|
const auto name = field->getLastText().trimmed();
|
||||||
if (name.isEmpty()) {
|
if (!ValidShortcutName(name)) {
|
||||||
field->showError();
|
field->showError();
|
||||||
} else {
|
} else {
|
||||||
submit(name, [weak = Ui::MakeWeak(box)] {
|
submit(name, [weak = Ui::MakeWeak(box)] {
|
||||||
|
|
Loading…
Add table
Reference in a new issue