[PR #1342] [MERGED] Fix importing csv files containing utf8 characters #2201

Closed
opened 2026-02-27 12:09:51 +03:00 by kerem · 0 comments
Owner

📋 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: masterHead: fix/utf8-csv-import


📝 Commits (2)

  • 425792d Fix importing csv files containing utf8 characters
  • 181b51f PEP 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 dict IMPORT_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.

## 📋 Pull Request Information **Original PR:** https://github.com/modoboa/modoboa/pull/1342 **Author:** [@ghost](https://github.com/ghost) **Created:** 1/3/2018 **Status:** ✅ Merged **Merged:** 1/9/2018 **Merged by:** [@tonioo](https://github.com/tonioo) **Base:** `master` ← **Head:** `fix/utf8-csv-import` --- ### 📝 Commits (2) - [`425792d`](https://github.com/modoboa/modoboa/commit/425792d23d92fcf57d201eb4bb8d664737eea99b) Fix importing csv files containing utf8 characters - [`181b51f`](https://github.com/modoboa/modoboa/commit/181b51f98642537df624740a0c0ff1df6cf9bb3a) PEP 8 fixes ### 📊 Changes **8 files changed** (+97 additions, -76 deletions) <details> <summary>View changed files</summary> 📝 `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) </details> ### 📄 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 dict `IMPORT_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 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-27 12:09:51 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/modoboa-modoboa#2201
No description provided.