From fcb5ff1e57d459516474ffd34c33bfa8b70e4304 Mon Sep 17 00:00:00 2001 From: Victoriano Giralt Date: Mon, 23 Jan 2023 18:47:06 +0100 Subject: [PATCH] Fix error when writting XML metadata with utf- characters --- djangosaml2idp/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/djangosaml2idp/models.py b/djangosaml2idp/models.py index 449fa31..43438d7 100644 --- a/djangosaml2idp/models.py +++ b/djangosaml2idp/models.py @@ -219,7 +219,7 @@ def metadata_path(self) -> str: # Rewrite the file if it did not exist yet, or if the SP config was updated after having written the file previously. if not os.path.exists(filename) or refreshed_metadata or (self.dt_updated and self.dt_updated.replace(tzinfo=pytz.utc) > datetime.datetime.fromtimestamp(os.path.getmtime(filename)).replace(tzinfo=pytz.utc)): try: - with open(filename, 'w') as f: + with open(filename, 'w', encoding='utf-8') as f: f.write(self.local_metadata) except Exception as e: logger.error(f'Could not write metadata to file {filename}: {e}')