| 278 | } |
| 279 | |
| 280 | auto 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 | } |
nothing calls this directly
no outgoing calls
no test coverage detected