ImportHelper class gives unicode errors when using a long string for filter_glob (file filters) #47252

Closed
opened 2016-01-27 10:20:19 +01:00 by hudson barkley · 6 comments

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\space_filebrowser.py", line 74, in draw
  row.label(params.filter_glob)
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.
**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\space_filebrowser.py", line 74, in draw row.label(params.filter_glob) 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", ``` 3. Run the script. The errors are triggered when the mouse moves in and out of the text input field.
Author

Changed status to: 'Open'

Changed status to: 'Open'
Author

Added subscriber: @snuq

Added subscriber: @snuq

Added subscriber: @mont29

Added subscriber: @mont29
Bastien Montagne self-assigned this 2016-01-27 17:56:26 +01:00

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

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

This issue was referenced by blender/blender@66aa4af836

This issue was referenced by blender/blender@66aa4af83611de2c59d9e8ab4ded1b48bec4a635

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'
Sign in to join this conversation.
No Milestone
No project
No Assignees
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender-addons#47252
No description provided.