Browse Source

query node - bytes converion utf-8 null character handling

ondratra 3 years ago
parent
commit
2adbf7d346
1 changed files with 8 additions and 1 deletions
  1. 8 1
      query-node/mappings/src/membership.ts

+ 8 - 1
query-node/mappings/src/membership.ts

@@ -210,7 +210,14 @@ function convertBytesToString(b: Bytes | null): string {
     return ''
   }
 
-  return Buffer.from(b.toU8a(true)).toString()
+  const result = Buffer.from(b.toU8a(true)).toString()
+
+  // prevent utf-8 null character
+  if (result.match(/^\0$/)) {
+    return ''
+  }
+
+  return result
 }
 
 function convertEntryMethod(entryMethod: EntryMethod): MembershipEntryMethod {