mirror of
https://github.com/modoboa/modoboa.git
synced 2026-04-26 01:16:01 +03:00
[PR #1342] [MERGED] Fix importing csv files containing utf8 characters #2201
Labels
No labels
bug
bug
dependencies
design
documentation
duplicate
enhancement
enhancement
enhancement
feedback-needed
help-needed
help-needed
installer
invalid
looking-for-sponsors
modoboa-contacts
new-ui
new-ui
pr
pull-request
pyconfr
python
question
security
stale
webmail
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/modoboa-modoboa#2201
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/modoboa/modoboa/pull/1342
Author: @ghost
Created: 1/3/2018
Status: ✅ Merged
Merged: 1/9/2018
Merged by: @tonioo
Base:
master← Head:fix/utf8-csv-import📝 Commits (2)
425792dFix importing csv files containing utf8 characters181b51fPEP 8 fixes📊 Changes
8 files changed (+97 additions, -76 deletions)
View changed files
📝
modoboa/admin/handlers.py(+19 -0)📝
modoboa/admin/management/commands/subcommands/_export.py(+2 -2)📝
modoboa/admin/management/commands/subcommands/_import.py(+10 -12)📝
modoboa/admin/tests/test_import_.py(+21 -1)📝
modoboa/admin/views/export.py(+3 -8)📝
modoboa/admin/views/import_.py(+34 -46)📝
modoboa/core/models.py(+7 -7)📝
requirements.txt(+1 -0)📄 Description
The csv module on Python 2 doesn't support utf8 (even encoded as bytes), the easiest fix is to use the csv module backported from Python 3.
I've also replaced
fct = getattr(lib, "import_%s" % row[0].strip())with a lookup dictIMPORT_OBJECT_TYPES. There's a potential here for somebody to attempt to call other functions with a csv import file.Fixes #1312
See https://docs.python.org/2/library/csv.html
See https://github.com/ryanhiebert/backports.csv
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.