Page MenuHome

ImportHelper class gives unicode errors when using a long string for filter_glob (file filters)
Closed, ResolvedPublic


Blender Version
Broken: 2.76

Short description of error
When using the ImportHelper or ExportHelper classes to enable a file browser dialog on an operator, enabling file extension filtering by setting the 'filter_glob' variable with a large amount of extensions will cause unicode errors such as:

File "C:\Program Files\Blender Foundation\Blender\2.76\scripts\startup\bl_ui\", line 74, in draw
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd2 in position 68: invalid continuation byte

Exact steps for others to reproduce the error

  1. In a text area, load in the python template "Operator File Import"
  2. Change line 32 (originally the line is 'default="*.txt",' to a long string. I used: default="*.cin;*.jpg;*.tga;*.bmp;*.rgb;*.dpx;*.sgi;*.tiff;*.png;*.hdr;*.dds;*.j2c;*.pdd;*.tx;*.tif;*.psd;*.psb;*.jp2;*.exr;*.jpeg;*.rgba",
  1. Run the script.

The errors are triggered when the mouse moves in and out of the text input field.

Event Timeline

hudson barkley (snuq) set Type to Bug.
hudson barkley (snuq) created this task.
hudson barkley (snuq) raised the priority of this task from to Needs Triage by Developer.
Bastien Montagne (mont29) claimed this task.

Yeah, this string shall never be more than 63 chars, we have a buffer overflow here, will fix both template and internal code.

Bastien Montagne (mont29) triaged this task as Confirmed, Medium priority.Jan 27 2016, 5:56 PM