0001-agendas-fix-import-event-crashing-with-nested-quotes.patch
chrono/manager/forms.py | ||
---|---|---|
1043 | 1043 | |
1044 | 1044 |
try: |
1045 | 1045 |
dialect = csv.Sniffer().sniff(content) |
1046 |
dialect.doublequote = True |
|
1046 | 1047 |
except csv.Error: |
1047 | 1048 |
dialect = None |
1048 | 1049 |
tests/manager/test_event.py | ||
---|---|---|
995 | 995 |
assert 'Identifier:' in resp.text # verbose_name is shown, not field name ('slug:') |
996 | 996 | |
997 | 997 | |
998 |
def test_import_event_nested_quotes(app, admin_user): |
|
999 |
agenda = Agenda(label='Foo bar') |
|
1000 |
agenda.save() |
|
1001 |
app = login(app) |
|
1002 | ||
1003 |
resp = app.get('/manage/agendas/%s/import-events' % agenda.id, status=200) |
|
1004 |
resp.form['events_csv_file'] = Upload( |
|
1005 |
't.csv', |
|
1006 |
','.join( |
|
1007 |
[ |
|
1008 |
"2016-09-16", |
|
1009 |
"18:00", |
|
1010 |
"10", |
|
1011 |
"5", |
|
1012 |
"éléphant", |
|
1013 |
"elephant", |
|
1014 |
# the multiline description and final dot |
|
1015 |
# and new line after ""éléphants"" are needed to trigger the bug. |
|
1016 |
'''"Animation: |
|
1017 |
De nombreux ""éléphants"". |
|
1018 |
"''', |
|
1019 |
] |
|
1020 |
).encode(), |
|
1021 |
'text/csv', |
|
1022 |
) |
|
1023 | ||
1024 |
resp = resp.form.submit(status=302) |
|
1025 |
assert Event.objects.count() == 1 |
|
1026 |
assert 'De nombreux "éléphants"' in Event.objects.all()[0].description |
|
1027 | ||
1028 | ||
998 | 1029 |
def test_import_events_existing_event(app, admin_user, freezer): |
999 | 1030 |
agenda = Agenda.objects.create(label='Foo bar') |
1000 | 1031 |
Desk.objects.create(agenda=agenda, slug='_exceptions_holder') |
1001 |
- |