diff --git a/app/models/etudiants.py b/app/models/etudiants.py index 359ca35e5d..30333a6b1a 100644 --- a/app/models/etudiants.py +++ b/app/models/etudiants.py @@ -136,9 +136,9 @@ class Identite(db.Model): "clé pour tris par ordre alphabétique" return ( scu.sanitize_string( - scu.suppress_accents(self.nom_usuel or self.nom or "").lower() - ), - scu.sanitize_string(scu.suppress_accents(self.prenom or "").lower()), + self.nom_usuel or self.nom or "", remove_spaces=False + ).lower(), + scu.sanitize_string(self.prenom or "", remove_spaces=False).lower(), ) def get_first_email(self, field="email") -> str: diff --git a/app/scodoc/sco_edit_ue.py b/app/scodoc/sco_edit_ue.py index 677c1ae491..def072c3c2 100644 --- a/app/scodoc/sco_edit_ue.py +++ b/app/scodoc/sco_edit_ue.py @@ -451,7 +451,7 @@ def ue_edit(ue_id=None, create=False, formation_id=None, default_semestre_idx=No """ else: modules_div = "" diff --git a/app/scodoc/sco_utils.py b/app/scodoc/sco_utils.py index 88dca7fde8..31de4bb228 100644 --- a/app/scodoc/sco_utils.py +++ b/app/scodoc/sco_utils.py @@ -588,7 +588,7 @@ def purge_chars(s, allowed_chars=""): return s.translate(PurgeChars(allowed_chars=allowed_chars)) -def sanitize_string(s): +def sanitize_string(s, remove_spaces=True): """s is an ordinary string, encoding given by SCO_ENCODING" suppress accents and chars interpreted in XML Irreversible (not a quote) @@ -596,8 +596,10 @@ def sanitize_string(s): For ids and some filenames """ # Table suppressing some chars: - trans = str.maketrans("", "", "'`\"<>!&\\ ") - return suppress_accents(s.translate(trans)).replace(" ", "_").replace("\t", "_") + to_del = "'`\"<>!&\\ " if remove_spaces else "'`\"<>!&" + trans = str.maketrans("", "", to_del) + + return suppress_accents(s.translate(trans)).replace("\t", "_") _BAD_FILENAME_CHARS = str.maketrans("", "", ":/\\&[]*?'")