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