Skip to content

Commit

Permalink
replace ILLEGAL_CHARACTERS_RE
Browse files Browse the repository at this point in the history
  • Loading branch information
willtho89 committed Jun 15, 2021
1 parent c82c66d commit 5f7be90
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions drf_renderer_xlsx/renderers.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from collections.abc import MutableMapping, Iterable
from django.utils.dateparse import parse_datetime
from openpyxl import Workbook
from openpyxl.cell.cell import ILLEGAL_CHARACTERS_RE
from openpyxl.styles import PatternFill, Border, Side, Alignment, Font, NamedStyle
from openpyxl.drawing.image import Image
from openpyxl.utils import get_column_letter
Expand Down Expand Up @@ -305,6 +306,7 @@ def _sanitize_value(self, raw_value):
# prepend ' if raw_value is starting with possible malicious char
if self.sanitize_fields and raw_value:
str_value = str(raw_value)
str_value = ILLEGAL_CHARACTERS_RE.sub('', str_value). # remove ILLEGAL_CHARACTERS so it does'nt crash
if str_value.startswith(ESCAPE_CHARS):
return "'" + raw_value
return raw_value
Expand Down

0 comments on commit 5f7be90

Please sign in to comment.