mirror of
https://github.com/Qz3rK/tdesktop.git
synced 2026-07-03 14:15:08 +02:00
Disallow hashtags of digits only.
This commit is contained in:
@@ -2487,12 +2487,16 @@ void DialogsInner::saveRecentHashtags(const QString &text) {
|
||||
--next;
|
||||
}
|
||||
}
|
||||
const auto tag = text.mid(i + 1, next - i - 1);
|
||||
if (TextUtilities::RegExpHashtagExclude().match(tag).hasMatch()) {
|
||||
continue;
|
||||
}
|
||||
if (!found && cRecentWriteHashtags().isEmpty() && cRecentSearchHashtags().isEmpty()) {
|
||||
Local::readRecentHashtagsAndBots();
|
||||
recent = cRecentSearchHashtags();
|
||||
}
|
||||
found = true;
|
||||
Stickers::IncrementRecentHashtag(recent, text.mid(i + 1, next - i - 1));
|
||||
Stickers::IncrementRecentHashtag(recent, tag);
|
||||
}
|
||||
if (found) {
|
||||
cSetRecentSearchHashtags(recent);
|
||||
|
||||
@@ -1365,12 +1365,16 @@ void MainWidget::saveRecentHashtags(const QString &text) {
|
||||
--next;
|
||||
}
|
||||
}
|
||||
const auto tag = text.mid(i + 1, next - i - 1);
|
||||
if (TextUtilities::RegExpHashtagExclude().match(tag).hasMatch()) {
|
||||
continue;
|
||||
}
|
||||
if (!found && cRecentWriteHashtags().isEmpty() && cRecentSearchHashtags().isEmpty()) {
|
||||
Local::readRecentHashtagsAndBots();
|
||||
recent = cRecentWriteHashtags();
|
||||
}
|
||||
found = true;
|
||||
Stickers::IncrementRecentHashtag(recent, text.mid(i + 1, next - i - 1));
|
||||
Stickers::IncrementRecentHashtag(recent, tag);
|
||||
}
|
||||
if (found) {
|
||||
cSetRecentWriteHashtags(recent);
|
||||
|
||||
@@ -40,6 +40,10 @@ QString ExpressionHashtag() {
|
||||
return qsl("(^|[") + ExpressionSeparators(qsl("`\\*/")) + qsl("])#[\\w]{2,64}([\\W]|$)");
|
||||
}
|
||||
|
||||
QString ExpressionHashtagExclude() {
|
||||
return qsl("^#?\\d+$");
|
||||
}
|
||||
|
||||
QString ExpressionMention() {
|
||||
return qsl("(^|[") + ExpressionSeparators(qsl("`\\*/")) + qsl("])@[A-Za-z_0-9]{1,32}([\\W]|$)");
|
||||
}
|
||||
@@ -1141,6 +1145,11 @@ const QRegularExpression &RegExpHashtag() {
|
||||
return result;
|
||||
}
|
||||
|
||||
const QRegularExpression &RegExpHashtagExclude() {
|
||||
static const auto result = CreateRegExp(ExpressionHashtagExclude());
|
||||
return result;
|
||||
}
|
||||
|
||||
const QRegularExpression &RegExpMention() {
|
||||
static const auto result = CreateRegExp(ExpressionMention());
|
||||
return result;
|
||||
@@ -1844,6 +1853,13 @@ void ParseEntities(TextWithEntities &result, int32 flags, bool rich) {
|
||||
if (!mHashtag.capturedRef(2).isEmpty()) {
|
||||
--hashtagEnd;
|
||||
}
|
||||
if (RegExpHashtagExclude().match(
|
||||
result.text.mid(
|
||||
hashtagStart + 1,
|
||||
hashtagEnd - hashtagStart - 1)).hasMatch()) {
|
||||
hashtagStart = INT_MAX;
|
||||
hashtagEnd = INT_MAX;
|
||||
}
|
||||
}
|
||||
while (mMention.hasMatch()) {
|
||||
if (!mMention.capturedRef(1).isEmpty()) {
|
||||
|
||||
@@ -160,6 +160,7 @@ const QRegularExpression &RegExpDomain();
|
||||
const QRegularExpression &RegExpDomainExplicit();
|
||||
const QRegularExpression &RegExpMailNameAtEnd();
|
||||
const QRegularExpression &RegExpHashtag();
|
||||
const QRegularExpression &RegExpHashtagExclude();
|
||||
const QRegularExpression &RegExpMention();
|
||||
const QRegularExpression &RegExpBotCommand();
|
||||
const QRegularExpression &RegExpMarkdownBold();
|
||||
|
||||
Reference in New Issue
Block a user