Page MenuHome

FBX Import: Fix failed to open FBX if it contains multibyte properties.
ClosedPublic

Authored by dano min (danomin) on Apr 17 2019, 4:47 PM.

Details

Summary

The following errors may occur if FBX contains multibyte properties:
"KeyError: 'ID property name length is limited to 63 characters"

The file where the problem occurred is here.
https://github.com/danominium/toko-chan-for-blender-bug-report/raw/master/Toko_win.FBX

My patch avoids this problem as follows:

  1. First replace the invalid byte. And get the correct byte length.
  2. Discard the last invalid byte generated when cutting out 55 bytes.

Decodeing with 'replace' may increase the byte length.
This is because invalid bytes are replaced with 3-byte REPLACEMENT CHARACTER (0xEF 0xBF 0xBD, U+FFFD).

ex)  Use the first 4 bytes, but get 6 bytes
b1 = 'ああ'.encode('utf-8')            # b'\xe3\x81\x82\xe3\x81\x82'
s  = b1[:4].decode('utf-8', 'replace') # 'あ�'
b2 = s.encode('utf-8')                 # b'\xe3\x81\x82\xef\xbf\xbd'
len(b2)                                # 6

Diff Detail

Event Timeline

Makes sense, will commit, thanks for the patch.

This revision is now accepted and ready to land.Thu, Aug 29, 11:34 AM

Oh, something similar have actually already been done in current code... thanks for the patch anyway.