Runtime setConf("username"/"channelname") skips anchoredPattern — same config validates differently before vs after restart
Description
In 1.6.870, validateUserName() / validateChannelName() are implemented as:
// Server.cpp (~line 2258)
bool Server::validateUserName(const QString &name) {
// ...
return qrUserName.match(name).hasMatch(); // substring match!
}QRegularExpression::match().hasMatch() is only a full match if the pattern is anchored. There are two code paths that construct qrUserName, and only one of them anchors:
// Path A: startup load (~line 468) — correctly anchored ✅
QString regex = qrUserName.pattern();
m_dbWrapper.getConfigurationTo(iServerNum, "username", regex);
qrUserName = QRegularExpression(QRegularExpression::anchoredPattern(std::move(regex)));
// Path B: runtime setConf handler (~line 604) — NOT anchored ❌
else if (key == "username")
qrUserName = !v.isNull() ? QRegularExpression(v) : Meta::mp->qrUserName;
// same for "channelname" (~line 606)The default pattern constructed in Meta.cpp (~line 110) is also unanchored; it only becomes effectively full-match because Path A re-wraps it at startup.
Result: the same configured value validates differently depending on how/when it was applied. A pattern set at runtime via ICE/DBUS setConf() accepts any name containing a matching substring; after a restart, the identical value from the database becomes a full-string match. Semantics silently change across a restart.
This discrepancy did not exist in 1.5, where validation used QRegExp::exactMatch() — inherently a full-string match regardless of anchoring.
Steps to reproduce
- Start Murmur 1.6.870 with default config
- At runtime, set the username pattern via ICE:
srv.setConf("username", "abc") - Use a name that only contains the pattern as a substring, e.g.
xxabcxx→ accepted (substring match) - Restart the server (the value persists in the DB config)
- Try
xxabcxxagain → rejected (startup path anchored the pattern → full match now enforced)
Mumble version
1.6.870
Mumble component
Server
OS
Linux
Reproducible?
Yes
Additional information
- Affects both
usernameandchannelname(identical handling in thesetConfhandler). - The
v.isNull()fallback toMeta::mp->qrUserNameis unanchored as well (Meta.cpp~line 110), so the "reset to default via setConf" path has the same issue. - Suggested fix: wrap the Path B construction with
QRegularExpression::anchoredPattern(...)exactly as Path A does, or anchor centrally insidevalidateUserName()/validateChannelName(). - Practical context: we set
username/channelnameat runtime via ICEsetConfas the documented workaround for the 1.5→1.6 non-ASCII regression (#7373), and discovered this anchoring discrepancy while auditing why a runtime-set config behaves differently from the same config after a restart. Same code area as #7373, but a distinct defect (per-path inconsistency rather than default-pattern semantics).
Relevant log output
# Path A (startup) wraps with anchoredPattern -> full match:
qrUserName = QRegularExpression(QRegularExpression::anchoredPattern(std::move(regex)));
# Path B (runtime setConf) does not -> substring match:
qrUserName = !v.isNull() ? QRegularExpression(v) : Meta::mp->qrUserName;
# validateUserName() relies on the pattern being anchored:
return qrUserName.match(name).hasMatch();Related to #7373.
Source: mumble-voip/mumble