diff options
Diffstat (limited to 'src/core/common')
-rw-r--r-- | src/core/common/Utils.cpp | 8 | ||||
-rw-r--r-- | src/core/common/Utils.hpp | 3 |
2 files changed, 7 insertions, 4 deletions
diff --git a/src/core/common/Utils.cpp b/src/core/common/Utils.cpp index 67920c2..f665db5 100644 --- a/src/core/common/Utils.cpp +++ b/src/core/common/Utils.cpp @@ -47,16 +47,18 @@ bool Utils::isIdentifierOrEmpty(const std::string &name) bool Utils::isNamespacedIdentifier(const std::string &name) { bool first = true; - for (char c : name) { + for (size_t i = 0; i < name.size(); i++) { + const char c = name[i]; if (first && !isIdentifierStartCharacter(c)) { return false; } - if (!first && (!isIdentifierCharacter(c) && c != ':')) { + if (!first && (!(isIdentifierCharacter(c) || c == ':') || + (c == ':' && !isIdentifierEndCharacter(name[i - 1])))) { return false; } first = (c == ':'); } - return !first; + return !first && isIdentifierEndCharacter(name.back()); } bool Utils::hasNonWhitepaceChar(const std::string &s) diff --git a/src/core/common/Utils.hpp b/src/core/common/Utils.hpp index c3b49a0..16bc5a1 100644 --- a/src/core/common/Utils.hpp +++ b/src/core/common/Utils.hpp @@ -101,7 +101,8 @@ public: /** * Returns true if the given string is in * \code{.txt} - * ([A-Za-z][A-Za-z0-9_-]*)(:[A-Za-z][A-Za-z0-9_-]*)* + * ([A-Za-z]([A-Za-z0-9_-][A-Za-z0-9])?) + * (:[A-Za-z]([A-Za-z0-9_-][A-Za-z0-9])?)* * \endCode * * @param name is the string that should be tested. |