aboutsummaryrefslogtreecommitdiffstats
path: root/src/core/utils/CommonUtils.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/utils/CommonUtils.cpp')
-rw-r--r--src/core/utils/CommonUtils.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/core/utils/CommonUtils.cpp b/src/core/utils/CommonUtils.cpp
index 0adc4d7f..ce36c71e 100644
--- a/src/core/utils/CommonUtils.cpp
+++ b/src/core/utils/CommonUtils.cpp
@@ -107,4 +107,11 @@ auto GPGFRONTEND_CORE_EXPORT ParseHexEncodedVersionTuple(const QString& s)
const auto version = s.toUtf8().toUInt(&ok, 16);
return ok ? static_cast<int>(version) : -1;
}
+
+const auto kReEmail = QRegularExpression{
+ R"((?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9]))\.){3}(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9])|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\]))"};
+
+auto GPGFRONTEND_CORE_EXPORT IsEmailAddress(const QString& str) -> bool {
+ return kReEmail.match(str).hasMatch();
+}
} // namespace GpgFrontend \ No newline at end of file