Univention Bugzilla – Bug 56403
Recommended file format is encoded to utf-8 instead of utf-16
Last modified: 2023-10-26 11:22:14 CEST
For compatibility reasons the recommended file format for class list exports is tab (\t) separated, utf16 (little-endian) encoded with a bom character at the start. Since https://forge.univention.org/bugzilla/show_bug.cgi?id=55102 however the file is encoded to utf8 instead.
I assume a patch could be: diff --git ucs-school-umc-lists/umc/python/schoollists/__init__.py ucs-school-umc-lists/umc/python/schoollists/__init__.py index 6e478cafa..1deefa9a5 100644 --- ucs-school-umc-lists/umc/python/schoollists/__init__.py +++ ucs-school-umc-lists/umc/python/schoollists/__init__.py @@ -73,7 +73,7 @@ class Instance(SchoolBaseModule): filename = os.path.join(path, os.path.basename(classlist)) try: with open(filename, "rb") as fd: - self.finished(request.id, fd.read(), mimetype="text/csv") + self.finished(request.id, fd.read(), mimetype='text/csv; charset="UTF-16"') except EnvironmentError: raise UMC_Error( _("The class list does not exists. Please create a new one."), @@ -122,9 +122,9 @@ class Instance(SchoolBaseModule): timestamp = datetime.now().strftime("%Y-%m-%d_%H_%M_%S") filename = "%s_%s-%s.csv" % (classlistname.replace("/", "_"), timestamp, uuid.uuid4()) path = os.path.join("/usr/share/ucs-school-umc-lists/classlists/", filename) - with open(path, "w") as fd: + with open(path, "wb") as fd: os.chmod(path, 0o600) - fd.write(write_classlist_csv(fieldnames, rows, separator)) + fd.write(write_classlist_csv(fieldnames, rows, separator).encode('utf-16')) url = "/univention/command/schoollists/csvlistget?classlist=%s" % (quote(filename),) self.finished(
Yes, sounds promising - Without looking into this further, we have two possible file formats and the other one should remain utf-8 encoded, does your proposal take this into account or will every file be utf-16?
Fixed with: Package: ucs-school-umc-lists Version: 3.0.9 Branch: ucs_5.0-0 Scope: ucs-school-5.0
Everything looks ok and Issue is closed: set to verify https://git.knut.univention.de/univention/ucsschool/-/issues/1079#note_223994
Errata updates for UCS@school 5.0 v4 have been released. https://docs.software-univention.de/ucsschool-changelog/5.0v4/en/changelog.html https://docs.software-univention.de/ucsschool-changelog/5.0v4/de/changelog.html If this error occurs again, please clone this bug.