summaryrefslogtreecommitdiff
path: root/src/core/common
diff options
context:
space:
mode:
authorBenjamin Paassen <bpaassen@techfak.uni-bielefeld.de>2015-03-02 15:52:34 +0100
committerBenjamin Paassen <bpaassen@techfak.uni-bielefeld.de>2015-03-02 15:52:34 +0100
commit522580cfdfc9e6dc3448240448c29533e68f240f (patch)
tree97c7129c897ff8c74de1dbec54312ec9962a6caa /src/core/common
parent5d6ee07995c7f59e66e0df558c8ebe7d2a8d1f68 (diff)
added check for witespace characters in Utils::isUserDefinedToken
Diffstat (limited to 'src/core/common')
-rw-r--r--src/core/common/Utils.cpp15
-rw-r--r--src/core/common/Utils.hpp1
2 files changed, 12 insertions, 4 deletions
diff --git a/src/core/common/Utils.cpp b/src/core/common/Utils.cpp
index 219b437..a87ff6d 100644
--- a/src/core/common/Utils.cpp
+++ b/src/core/common/Utils.cpp
@@ -124,7 +124,8 @@ bool Utils::isUserDefinedToken(const std::string &token)
// Make sure the token meets is neither empty, nor starts or ends with an
// alphanumeric character
const size_t len = token.size();
- if (len == 0 || isAlphanumeric(token[0]) || isAlphanumeric(token[len - 1])) {
+ if (len == 0 || isAlphanumeric(token[0]) ||
+ isAlphanumeric(token[len - 1])) {
return false;
}
@@ -134,13 +135,19 @@ bool Utils::isUserDefinedToken(const std::string &token)
return false;
}
+ // Make sure the token does not contain any whitespaces.
+ for (char c : token) {
+ if (isWhitespace(c)) {
+ return false;
+ }
+ }
+
// Make sure the token contains other characters but { and }
- for (char c: token) {
+ for (char c : token) {
if (c != '{' && c != '}') {
return true;
}
}
return false;
}
-}
-
+} \ No newline at end of file
diff --git a/src/core/common/Utils.hpp b/src/core/common/Utils.hpp
index 25a4de5..d9e26da 100644
--- a/src/core/common/Utils.hpp
+++ b/src/core/common/Utils.hpp
@@ -117,6 +117,7 @@ public:
* <li>'%', '%{', '}%'</li>
* </ul>
* </li>
+ * <li>The token does not contain any whitespaces.</li>
* </ul>
*/
static bool isUserDefinedToken(const std::string &token);