Skip to content

Commit

Permalink
[FIX] Check if name isn't empty before executing regex.
Browse files Browse the repository at this point in the history
  • Loading branch information
adrienpeiffer committed Aug 16, 2017
1 parent 78014ff commit e981765
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions odoo/tools/misc.py
Expand Up @@ -372,11 +372,12 @@ class PatchedXlsxWorkbook(xlsxwriter.Workbook):

# TODO when xlsxwriter bump to 0.9.8, add worksheet_class=None parameter instead of kw
def add_worksheet(self, name=None, **kw):
# invalid Excel character: []:*?/\
name = re.sub(r'[\[\]:*?/\\]', '', name)
if name:
# invalid Excel character: []:*?/\
name = re.sub(r'[\[\]:*?/\\]', '', name)

# maximum size is 31 characters
name = name[:31]
# maximum size is 31 characters
name = name[:31]
return super(PatchedXlsxWorkbook, self).add_worksheet(name, **kw)

xlsxwriter.Workbook = PatchedXlsxWorkbook
Expand Down

0 comments on commit e981765

Please sign in to comment.