Prevent user from entering incorrect characters in Live Notifications channels list (#3715)
Co-authored-by: Sidd <iProdigy@users.noreply.github.com> Co-authored-by: Rasmus Karlsson <rasmus.karlsson@pajlada.com>
This commit is contained in:
@@ -5,6 +5,12 @@
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
namespace {
|
||||
|
||||
const auto TWITCH_USER_LOGIN_PATTERN = R"(^[a-z0-9]\w{0,24}$)";
|
||||
|
||||
} // namespace
|
||||
|
||||
void openTwitchUsercard(QString channel, QString username)
|
||||
{
|
||||
QDesktopServices::openUrl("https://www.twitch.tv/popout/" + channel +
|
||||
@@ -35,4 +41,20 @@ void stripChannelName(QString &channelName)
|
||||
}
|
||||
}
|
||||
|
||||
QRegularExpression twitchUserNameRegexp()
|
||||
{
|
||||
static QRegularExpression re(
|
||||
TWITCH_USER_LOGIN_PATTERN,
|
||||
QRegularExpression::PatternOption::CaseInsensitiveOption);
|
||||
|
||||
return re;
|
||||
}
|
||||
|
||||
QRegularExpression twitchUserLoginRegexp()
|
||||
{
|
||||
static QRegularExpression re(TWITCH_USER_LOGIN_PATTERN);
|
||||
|
||||
return re;
|
||||
}
|
||||
|
||||
} // namespace chatterino
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <QRegularExpression>
|
||||
#include <QString>
|
||||
|
||||
namespace chatterino {
|
||||
@@ -12,4 +13,16 @@ void stripUserName(QString &userName);
|
||||
// stripChannelName removes any @ prefix or , suffix to make it more suitable for command use
|
||||
void stripChannelName(QString &channelName);
|
||||
|
||||
// Matches a strict Twitch user login.
|
||||
// May contain lowercase a-z, 0-9, and underscores
|
||||
// Must contain between 1 and 25 characters
|
||||
// Must not start with an underscore
|
||||
QRegularExpression twitchUserLoginRegexp();
|
||||
|
||||
// Matches a loose Twitch user login name.
|
||||
// May contain lowercase and uppercase a-z, 0-9, and underscores
|
||||
// Must contain between 1 and 25 characters
|
||||
// Must not start with an underscore
|
||||
QRegularExpression twitchUserNameRegexp();
|
||||
|
||||
} // namespace chatterino
|
||||
|
||||
Reference in New Issue
Block a user