From 8245b8036c8bdc51625616ca6248b0f2b0271dc0 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Tue, 4 Sep 2012 09:46:19 +0300 Subject: [PATCH 1/1] Refuse to encode invalid Unicode characters in UTF-8 --- source/stringcodec/utf8.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/stringcodec/utf8.cpp b/source/stringcodec/utf8.cpp index c6d1990..b75b397 100644 --- a/source/stringcodec/utf8.cpp +++ b/source/stringcodec/utf8.cpp @@ -7,7 +7,7 @@ namespace StringCodec { void Utf8::Encoder::encode_char(unichar ch, string &buf) { - if(ch<0 || ch>0x10FFFF) + if(!is_valid_unichar(ch)) return error(ch, buf, invalid_character(ch, "UTF-8")); unsigned bytes = 1; -- 2.43.0