From bd4ff81e324f418ea191e57b48fd7dd7669947b1 Mon Sep 17 00:00:00 2001 From: rjawor Date: Sun, 15 Oct 2017 18:54:15 +0200 Subject: [PATCH] ensuring UTF-8 strings --- concordia/common/text_utils.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/concordia/common/text_utils.cpp b/concordia/common/text_utils.cpp index c7704bd..91049de 100644 --- a/concordia/common/text_utils.cpp +++ b/concordia/common/text_utils.cpp @@ -2,6 +2,8 @@ #include #include #include +#include "utf8/utf8.h" + TextUtils::TextUtils() { _lowerConverter = @@ -11,6 +13,9 @@ TextUtils::TextUtils() { } std::string TextUtils::toLowerCase(const std::string & text) { + if (!utf8::is_valid(text.begin(), text.end())) { + throw ConcordiaException("Bad input encoding, use UTF-8"); + } return simpleConvert(*_lowerConverter, text); }