{
QString suffix = v.toString();
QString letter = "A-Za-z";
- QString special = "\x5b-\x60\x7b-\x7d";
+ QString special = "\x5b-\x60\x7b-\x7d"; // NOLINT(modernize-raw-string-literal)
_nickRx = QRegExp(QString("^([%1%2][%1%2\\d-]*)%3").arg(letter, special, suffix).trimmed());
}
_bufferInfo = info;
QString params;
- QRegExp rx("^\\s*(\\S+)(\\s+(.*))?$");
+ QRegExp rx(R"(^\s*(\S+)(\s+(.*))?$)");
if (!rx.exactMatch(command)) {
emit error(tr("Invalid command string for /exec: %1").arg(command));
}
// Make sure we don't execute something outside a script dir
if (_scriptName.contains("../") || _scriptName.contains("..\\"))
- emit error(tr("Name \"%1\" is invalid: ../ or ..\\ are not allowed!").arg(_scriptName));
+ emit error(tr(R"(Name "%1" is invalid: ../ or ..\ are not allowed!)").arg(_scriptName));
else {
foreach(QString scriptDir, Quassel::scriptDirPaths()) {
return;
}
- QRegExp paramRangeR("\\$(\\d+)\\.\\.(\\d*)");
+ QRegExp paramRangeR(R"(\$(\d+)\.\.(\d*))");
QStringList commands = alias.split(QRegExp("; ?"));
QStringList params = msg.split(' ');
QStringList expandedCommands;
#endif
// cleaning forbidden characters from nick
- QRegExp rx(QString("(^[\\d-]+|[^A-Za-z0-9\x5b-\x60\x7b-\x7d])"));
+ QRegExp rx(QString("(^[\\d-]+|[^A-Za-z0-9\x5b-\x60\x7b-\x7d])")); // NOLINT(modernize-raw-string-literal)
nick.remove(rx);
return nick;
}
id = info.networkId.toInt();
if (!_networks.contains(id)) {
// create persistent chans
- QRegExp rx("\\s*(\\S+)(?:\\s*(\\S+))?\\s*");
+ QRegExp rx(R"(\s*(\S+)(?:\s*(\S+))?\s*)");
foreach(QString channel, persistentChans) {
if (!rx.exactMatch(channel)) {
qWarning() << QString("Invalid persistent channel declaration: %1").arg(channel);
return;
}
- static QRegExp ipAddress("\\d+\\.\\d+\\.\\d+\\.\\d+");
+ static QRegExp ipAddress(R"(\d+\.\d+\.\d+\.\d+)");
if (ipAddress.exactMatch(generalizedHost)) {
int lastDotPos = generalizedHost.lastIndexOf('.') + 1;
generalizedHost.replace(lastDotPos, generalizedHost.length() - lastDotPos, '*');
void CtcpParser::setStandardCtcp(bool enabled)
{
- QByteArray XQUOTE = QByteArray("\134");
+ QByteArray XQUOTE = QByteArray(R"(\)");
if (enabled)
_ctcpXDelimDequoteHash[XQUOTE + XQUOTE] = XQUOTE;
else
// :ChanServ!ChanServ@services. NOTICE egst :[#apache] Welcome, this is #apache. Please read the in-channel topic message. This channel is being logged by IRSeekBot. If you have any question please see http://blog.freenode.net/?p=68
if (!net->isChannelName(target)) {
QString decMsg = net->serverDecode(params.at(1));
- QRegExp welcomeRegExp("^\\[([^\\]]+)\\] ");
+ QRegExp welcomeRegExp(R"(^\[([^\]]+)\] )");
if (welcomeRegExp.indexIn(decMsg) != -1) {
QString channelname = welcomeRegExp.cap(1);
decMsg = decMsg.mid(welcomeRegExp.matchedLength());
// now test if message consists only of two dns names as the RFC requests
// but also allow the commonly used "*.net *.split"
- QRegExp hostRx("^(?:[\\w\\d-.]+|\\*)\\.[\\w\\d-]+\\s(?:[\\w\\d-.]+|\\*)\\.[\\w\\d-]+$");
+ QRegExp hostRx(R"(^(?:[\w\d-.]+|\*)\.[\w\d-]+\s(?:[\w\d-.]+|\*)\.[\w\d-]+$)");
if (hostRx.exactMatch(quitMessage))
return true;
// the ability to bind to an IP on client sockets.
_quasselStanzaTemplate = QString("lport %1 { reply \"%2\" } #%3\n");
- _quasselStanzaRx = QRegExp(QString("^lport .* \\{ .* \\} #%1\\r?\\n").arg(_configTag));
+ _quasselStanzaRx = QRegExp(QString(R"(^lport .* \{ .* \} #%1\r?\n)").arg(_configTag));
// initially remove all Quassel stanzas that might be present
if (parseConfig(false) && writeConfig())
// (^\s*\(.+\)\s*$)|(^\s*\{.+\}\s*$)|(^\s*\[.+\]\s*$)|(^\s*<.+>\s*$)
// Note that '\' must be escaped as '\\'
// Helpful interactive website for debugging and explaining: https://regex101.com/
- const QRegExp regExpMatchBrackets("^\\s*[({[<].+[)}\\]>]\\s*$");
+ const QRegExp regExpMatchBrackets(R"(^\s*[({[<].+[)}\]>]\s*$)");
_timestampHasBrackets = regExpMatchBrackets.exactMatch(_timestampFormatString);
}
}
out << "\n// NickView Colors\n"
<< "NickListItem[type=\"category\"] { foreground: " << color("DefaultBuffer", uiColors) << "; }\n"
<< "NickListItem[type=\"user\"] { foreground: " << color("OnlineNick", uiColors) << "; }\n"
- << "NickListItem[type=\"user\", state=\"away\"] { foreground: " << color("AwayNick", uiColors) << "; }\n";
+ << R"(NickListItem[type="user", state="away"] { foreground: )" << color("AwayNick", uiColors) << "; }\n";
}
settingsQss.close();
// define a regexp for valid nicknames
// TODO: add max nicklength according to ISUPPORT
QString letter = "A-Za-z";
- QString special = "\x5b-\x60\x7b-\x7d";
+ QString special = R"([-`{-})";
QRegExp rx(QString("[%1%2][%1%2\\d-]*").arg(letter, special));
ui.nickEdit->setValidator(new QRegExpValidator(rx, ui.nickEdit));
if (old.isEmpty()) {
ClickableList ClickableList::fromString(const QString &str)
{
// For matching URLs
- static QString scheme("(?:(?:mailto:|(?:[+.-]?\\w)+://)|www(?=\\.\\S+\\.))");
- static QString authority("(?:(?:[,.;@:]?[-\\w]+)+\\.?|\\[[0-9a-f:.]+\\])(?::\\d+)?");
+ static QString scheme(R"((?:(?:mailto:|(?:[+.-]?\w)+://)|www(?=\.\S+\.)))");
+ static QString authority(R"((?:(?:[,.;@:]?[-\w]+)+\.?|\[[0-9a-f:.]+\])(?::\d+)?)");
static QString urlChars("(?:[,.;:]*[\\w~@/?&=+$()!%#*-])");
- static QString urlEnd("(?:>|[,.;:\"]*\\s|\\b|$)");
+ static QString urlEnd("(?:>|[,.;:\"]*\\s|\\b|$)"); // NOLINT(modernize-raw-string-literal)
static QRegExp regExp[] = {
// URL
// Channel name
// We don't match for channel names starting with + or &, because that gives us a lot of false positives.
- QRegExp("((?:#|![A-Z0-9]{5})[^,:\\s]+(?::[^,:\\s]+)?)\\b", Qt::CaseInsensitive)
+ QRegExp(R"(((?:#|![A-Z0-9]{5})[^,:\s]+(?::[^,:\s]+)?)\b)", Qt::CaseInsensitive)
// TODO: Nicks, we'll need a filtering for only matching known nicknames further down if we do this
};
QString ident = userFromMask(hostmask);
QString host = hostFromMask(hostmask);
QString domain = host;
- QRegExp domainRx = QRegExp("(\\.[^.]+\\.\\w+\\D)$");
+ QRegExp domainRx = QRegExp(R"((\.[^.]+\.\w+\D)$)");
if (domainRx.indexIn(host) != -1)
domain = domainRx.cap(1);
// we can't rely on who-data
return;
// Remove C-style comments /* */ or //
- static QRegExp commentRx("(//.*(\\n|$)|/\\*.*\\*/)");
+ static QRegExp commentRx(R"((//.*(\n|$)|/\*.*\*/))");
commentRx.setMinimal(true);
ss.remove(commentRx);
const std::pair<UiStyle::FormatType, UiStyle::MessageLabel> invalid{FormatType::Invalid, MessageLabel::None};
- static const QRegExp rx("ChatLine(?:::(\\w+))?(?:#([\\w\\-]+))?(?:\\[([=-,\\\"\\w\\s]+)\\])?");
+ static const QRegExp rx(R"(ChatLine(?:::(\w+))?(?:#([\w\-]+))?(?:\[([=-,\"\w\s]+)\])?)");
// $1: subelement; $2: msgtype; $3: conditionals
if (!rx.exactMatch(decl)) {
qWarning() << Q_FUNC_INFO << tr("Invalid block declaration: %1").arg(decl);
}
// Next up: conditional (formats, labels, nickhash)
- static const QRegExp condRx("\\s*([\\w\\-]+)\\s*=\\s*\"(\\w+)\"\\s*");
+ static const QRegExp condRx(R"lit(\s*([\w\-]+)\s*=\s*"(\w+)"\s*)lit");
if (!conditions.isEmpty()) {
foreach(const QString &cond, conditions.split(',', QString::SkipEmptyParts)) {
if (!condRx.exactMatch(cond)) {
{
using ItemFormatType = UiStyle::ItemFormatType;
- static const QRegExp rx("(Chat|Nick)ListItem(?:\\[([=-,\\\"\\w\\s]+)\\])?");
+ static const QRegExp rx(R"((Chat|Nick)ListItem(?:\[([=-,\"\w\s]+)\])?)");
// $1: item type; $2: properties
if (!rx.exactMatch(decl)) {
qWarning() << Q_FUNC_INFO << tr("Invalid block declaration: %1").arg(decl);
QString type, state;
if (!properties.isEmpty()) {
QHash<QString, QString> props;
- static const QRegExp propRx("\\s*([\\w\\-]+)\\s*=\\s*\"([\\w\\-]+)\"\\s*");
+ static const QRegExp propRx(R"lit(\s*([\w\-]+)\s*=\s*"([\w\-]+)"\s*)lit");
foreach(const QString &prop, properties.split(',', QString::SkipEmptyParts)) {
if (!propRx.exactMatch(prop)) {
qWarning() << Q_FUNC_INFO << tr("Invalid proplist %1").arg(prop);
// [0-9] Match any digit from 0-9
// Note that '\' must be escaped as '\\'
// Helpful interactive website for debugging and explaining: https://regex101.com/
- static const QRegExp rx("palette\\s*\\(\\s*([a-z-0-9]+)\\s*\\)");
+ static const QRegExp rx(R"(palette\s*\(\s*([a-z-0-9]+)\s*\))");
if (!rx.exactMatch(str)) {
qWarning() << Q_FUNC_INFO << tr("Invalid palette color role specification: %1").arg(str);
return QBrush();
return QBrush();
}
else if (str.startsWith("qlineargradient")) {
- static const QString rxFloat("\\s*(-?\\s*[0-9]*\\.?[0-9]+)\\s*");
- static const QRegExp rx(QString("qlineargradient\\s*\\(\\s*x1:%1,\\s*y1:%1,\\s*x2:%1,\\s*y2:%1,(.+)\\)").arg(rxFloat));
+ static const QString rxFloat(R"(\s*(-?\s*[0-9]*\.?[0-9]+)\s*)");
+ static const QRegExp rx(QString(R"(qlineargradient\s*\(\s*x1:%1,\s*y1:%1,\s*x2:%1,\s*y2:%1,(.+)\))").arg(rxFloat));
if (!rx.exactMatch(str)) {
qWarning() << Q_FUNC_INFO << tr("Invalid gradient declaration: %1").arg(str);
return QBrush();
return QBrush(gradient);
}
else if (str.startsWith("qconicalgradient")) {
- static const QString rxFloat("\\s*(-?\\s*[0-9]*\\.?[0-9]+)\\s*");
- static const QRegExp rx(QString("qconicalgradient\\s*\\(\\s*cx:%1,\\s*cy:%1,\\s*angle:%1,(.+)\\)").arg(rxFloat));
+ static const QString rxFloat(R"(\s*(-?\s*[0-9]*\.?[0-9]+)\s*)");
+ static const QRegExp rx(QString(R"(qconicalgradient\s*\(\s*cx:%1,\s*cy:%1,\s*angle:%1,(.+)\))").arg(rxFloat));
if (!rx.exactMatch(str)) {
qWarning() << Q_FUNC_INFO << tr("Invalid gradient declaration: %1").arg(str);
return QBrush();
return QBrush(gradient);
}
else if (str.startsWith("qradialgradient")) {
- static const QString rxFloat("\\s*(-?\\s*[0-9]*\\.?[0-9]+)\\s*");
- static const QRegExp rx(QString("qradialgradient\\s*\\(\\s*cx:%1,\\s*cy:%1,\\s*radius:%1,\\s*fx:%1,\\s*fy:%1,(.+)\\)").arg(rxFloat));
+ static const QString rxFloat(R"(\s*(-?\s*[0-9]*\.?[0-9]+)\s*)");
+ static const QRegExp rx(QString(R"(qradialgradient\s*\(\s*cx:%1,\s*cy:%1,\s*radius:%1,\s*fx:%1,\s*fy:%1,(.+)\))").arg(rxFloat));
if (!rx.exactMatch(str)) {
qWarning() << Q_FUNC_INFO << tr("Invalid gradient declaration: %1").arg(str);
return QBrush();
QssParser::ColorTuple QssParser::parseColorTuple(const QString &str)
{
ColorTuple result;
- static const QRegExp rx("\\(((\\s*[0-9]{1,3}%?\\s*)(,\\s*[0-9]{1,3}%?\\s*)*)\\)");
+ static const QRegExp rx(R"(\(((\s*[0-9]{1,3}%?\s*)(,\s*[0-9]{1,3}%?\s*)*)\))");
if (!rx.exactMatch(str.trimmed())) {
return ColorTuple();
}
QString str = str_;
QGradientStops result;
static const QString rxFloat("(0?\\.[0-9]+|[01])"); // values between 0 and 1
- static const QRegExp rx(QString("\\s*,?\\s*stop:\\s*(%1)\\s+([^:]+)(,\\s*stop:|$)").arg(rxFloat));
+ static const QRegExp rx(QString(R"(\s*,?\s*stop:\s*(%1)\s+([^:]+)(,\s*stop:|$))").arg(rxFloat));
int idx;
while ((idx = rx.indexIn(str)) == 0) {
qreal x = rx.cap(1).toDouble();
if (!_currentNetwork)
return;
- QString tabAbbrev = _lineEdit->text().left(_lineEdit->cursorPosition()).section(QRegExp("[^#\\w\\d-_\\[\\]{}|`^.\\\\]"), -1, -1);
- QRegExp regex(QString("^[-_\\[\\]{}|`^.\\\\]*").append(QRegExp::escape(tabAbbrev)), Qt::CaseInsensitive);
+ QString tabAbbrev = _lineEdit->text().left(_lineEdit->cursorPosition()).section(QRegExp(R"([^#\w\d-_\[\]{}|`^.\\])"), -1, -1);
+ QRegExp regex(QString(R"(^[-_\[\]{}|`^.\\]*)").append(QRegExp::escape(tabAbbrev)), Qt::CaseInsensitive);
// channel completion - add all channels of the current network to the map
if (tabAbbrev.startsWith('#')) {