Repository: lucy-clownfish
Updated Branches:
  refs/heads/master 946d25a6a -> cdbcf1b3c


Make CB_VCatF throw on invalid UTF-8

Additional test cases will be added when addressing CLOWNFISH-95.

Fixes CLOWNFISH-96.


Project: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/commit/06b98230
Tree: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/tree/06b98230
Diff: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/diff/06b98230

Branch: refs/heads/master
Commit: 06b982309c0cf0797e3beaff87bf142707617b0a
Parents: cb0bb2c
Author: Nick Wellnhofer <[email protected]>
Authored: Thu May 12 15:53:54 2016 +0200
Committer: Nick Wellnhofer <[email protected]>
Committed: Fri May 13 15:55:08 2016 +0200

----------------------------------------------------------------------
 runtime/core/Clownfish/CharBuf.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/06b98230/runtime/core/Clownfish/CharBuf.c
----------------------------------------------------------------------
diff --git a/runtime/core/Clownfish/CharBuf.c b/runtime/core/Clownfish/CharBuf.c
index eb4f92f..33bbca6 100644
--- a/runtime/core/Clownfish/CharBuf.c
+++ b/runtime/core/Clownfish/CharBuf.c
@@ -124,6 +124,7 @@ CB_VCatF_IMP(CharBuf *self, const char *pattern, va_list 
args) {
         while (slice_end < pattern_end && *slice_end != '%') { slice_end++; }
         if (pattern != slice_end) {
             ptrdiff_t size = slice_end - pattern;
+            VALIDATE_UTF8(pattern, size);
             S_cat_utf8(self, pattern, (size_t)size);
             pattern = slice_end;
         }
@@ -225,12 +226,8 @@ CB_VCatF_IMP(CharBuf *self, const char *pattern, va_list 
args) {
                         }
                         else {
                             size_t size = strlen(string);
-                            if (StrHelp_utf8_valid(string, size)) {
-                                S_cat_utf8(self, string, size);
-                            }
-                            else {
-                                S_cat_utf8(self, "[INVALID UTF8]", 14);
-                            }
+                            VALIDATE_UTF8(string, size);
+                            S_cat_utf8(self, string, size);
                         }
                     }
                     break;

Reply via email to