Skip to content

Commit

Permalink
Handle special characters in forms (wooey#296)
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris7 authored Oct 13, 2019
1 parent 4a2e31c commit 8f18281
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion wooey/forms/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def render(name, value=None, attrs=None, renderer=None):

def multi_value_from_datadict(func):
def value_from_datadict(data, files, name):
return [func(QueryDict('{name}={value}'.format(name=name, value=i)), files, name) for i in data.getlist(name)]
return [func(QueryDict('{name}={value}'.format(name=name, value=six.moves.urllib.parse.quote(i))), files, name) for i in data.getlist(name)]
return value_from_datadict


Expand Down
11 changes: 11 additions & 0 deletions wooey/tests/test_forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,3 +219,14 @@ def test_form_with_custom_widget(self):
'class': 'custom',
}
)

def test_handles_special_characters(self):
script_version = self.choice_script
# Associate a custom widget with a field
choice_str_slug = test_utils.get_subparser_form_slug(script_version, 'choices_str')
choice_str = 'This & is special'
form = utils.get_master_form(script_version=script_version)
qdict = self.get_mvdict({choice_str_slug: [choice_str], 'wooey_type': [script_version.pk], 'job_name': ['abc']})
utils.validate_form(form=form, data=qdict)
self.assertTrue(form.is_valid(), form.errors)
self.assertEqual(form.cleaned_data[choice_str_slug], [choice_str])

0 comments on commit 8f18281

Please sign in to comment.