]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Switch utf::string from g_utf8_validate to Unicode_IsBufferValid.
authorVMware, Inc <>
Wed, 18 Sep 2013 03:26:17 +0000 (20:26 -0700)
committerDmitry Torokhov <dmitry.torokhov@gmail.com>
Mon, 23 Sep 2013 05:06:59 +0000 (22:06 -0700)
In the version of glib we currently use g_utf8_validate rejects strings
containing the non-characters U+FFFE and U+FFFF. This was marked as a
bug and resolved (see https://bugzilla.gnome.org/show_bug.cgi?id=694669)
but until that is released we need a workaround. Our internal UTF-8
validation routine accepts these characters as valid so use that
instead.

Signed-off-by: Dmitry Torokhov <dtor@vmware.com>
open-vm-tools/services/plugins/dndcp/stringxx/string.cc

index ea502d87fba2d5b1ec022f5ed499fb85558af6dd..c816341ee24c47d9c60d468aca655935fb79d181 100644 (file)
@@ -2049,9 +2049,11 @@ string::end()
 bool
 Validate(const Glib::ustring& s) // IN
 {
-   bool isValid = s.validate();
+   bool isValid = Unicode_IsBufferValid(s.c_str(), s.bytes(),
+                                        STRING_ENCODING_UTF8);
    if (!isValid) {
-      char *escaped = Unicode_EscapeBuffer(s.c_str(), -1, STRING_ENCODING_UTF8);
+      char *escaped = Unicode_EscapeBuffer(s.c_str(), s.bytes(),
+                                           STRING_ENCODING_UTF8);
       Warning("Invalid UTF-8 string: \"%s\"\n", escaped);
       free(escaped);
    }