MCPcopy Create free account
hub / github.com/IJHack/QtPass / isValidKeyId

Method isValidKeyId

src/util.cpp:280–301  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

278}
279
280auto Util::isValidKeyId(const QString &keyId) -> bool {
281 static const QRegularExpression hexPrefixRegex{"^0[xX]"};
282 static const QRegularExpression specialPrefixRegex{"^[@/#&]"};
283 static const QRegularExpression hexKeyIdRegex{"^[0-9A-Fa-f]{8,40}$"};
284
285 if (keyId.isEmpty()) {
286 return false;
287 }
288
289 QString normalized = keyId;
290 if (normalized.startsWith('<') && normalized.endsWith('>')) {
291 normalized = normalized.mid(1, normalized.length() - 2);
292 }
293 normalized.remove(hexPrefixRegex);
294
295 if (specialPrefixRegex.match(normalized).hasMatch() ||
296 normalized.contains('@')) {
297 return true;
298 }
299
300 return hexKeyIdRegex.match(normalized).hasMatch();
301}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected