13983 fix escape handling

This commit is contained in:
Arthur 2023-12-12 13:59:14 -08:00
parent f509c65f3d
commit f49c310f23
2 changed files with 5 additions and 3 deletions

View File

@ -96,8 +96,6 @@ class CustomFieldChoiceSetImportForm(CSVModelForm):
for line in self.cleaned_data['extra_choices']: for line in self.cleaned_data['extra_choices']:
try: try:
value, label = re.split(r'(?<!\\):', line, maxsplit=1) value, label = re.split(r'(?<!\\):', line, maxsplit=1)
value = value.replace('\\:', ':')
label = label.replace('\\:', ':')
except ValueError: except ValueError:
value, label = line, line value, label = line, line
data.append((value, label)) data.append((value, label))

View File

@ -748,7 +748,11 @@ class CustomFieldChoiceSet(CloningMixin, ExportTemplatesMixin, ChangeLoggedModel
if self.base_choices: if self.base_choices:
self._choices.extend(CHOICE_SETS.get(self.base_choices)) self._choices.extend(CHOICE_SETS.get(self.base_choices))
if self.extra_choices: if self.extra_choices:
self._choices.extend(self.extra_choices) extra_choices = []
for choice in self.extra_choices:
choice = (choice[0], choice[1].replace('\\:', ':'))
extra_choices.append(choice)
self._choices.extend(extra_choices)
if self.order_alphabetically: if self.order_alphabetically:
self._choices = sorted(self._choices, key=lambda x: x[0]) self._choices = sorted(self._choices, key=lambda x: x[0])
return self._choices return self._choices