From 4a245b0bb995b6a78702941b837207ebefc39c89 Mon Sep 17 00:00:00 2001
From: Rolf Niepraschk <Rolf.Niepraschk@ptb.de>
Date: Mon, 30 Nov 2020 13:00:16 +0100
Subject: [PATCH] "canonicalize(...)" added

---
 setup.py                           | 6 +++++-
 templates/xml/calibration_item.xml | 2 +-
 templates/xml/used_methods.xml     | 2 +-
 trans.py                           | 3 ++-
 utils.py                           | 2 +-
 5 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/setup.py b/setup.py
index 21184c0..5fcbaed 100644
--- a/setup.py
+++ b/setup.py
@@ -148,7 +148,11 @@ setup(
     #
     # For an analysis of "install_requires" vs pip's requirements files see:
     # https://packaging.python.org/en/latest/requirements.html
-    install_requires=['peppercorn'],  # Optional
+    install_requires=[
+    'lxml',
+    'prettierfier',
+    'flask'
+    ],  # Optional
 
     # List additional groups of dependencies here (e.g. development
     # dependencies). Users will be able to install these using the "extras"
diff --git a/templates/xml/calibration_item.xml b/templates/xml/calibration_item.xml
index 66f5e70..aa494ec 100644
--- a/templates/xml/calibration_item.xml
+++ b/templates/xml/calibration_item.xml
@@ -24,7 +24,7 @@
       {%- for j in i['description'] %}
       <dcc:content lang="{{j.lang}}">
         {%- for k in j.content %}
-        {{utils.sanitize_ltx(k)|safe}}
+        {{k|safe}}
         {% endfor -%}
       </dcc:content>
       {% endfor -%}
diff --git a/templates/xml/used_methods.xml b/templates/xml/used_methods.xml
index b750d52..2fccbec 100644
--- a/templates/xml/used_methods.xml
+++ b/templates/xml/used_methods.xml
@@ -14,7 +14,7 @@
       {%- for j in i['description'] %}
       <dcc:content lang="{{j.lang}}">
         {%- for k in j.content %}
-        {{utils.sanitize_ltx(k)|safe}}
+        {{k|safe}}
         {% endfor -%}
       </dcc:content>
       {% endfor -%}
diff --git a/trans.py b/trans.py
index f0af9af..e0ddd86 100644
--- a/trans.py
+++ b/trans.py
@@ -2,6 +2,7 @@ from flask import Flask, render_template
 
 import utils as utils
 import os
+from lxml import etree
 from prettierfier import prettify_xml
 
 config = utils.config
@@ -22,7 +23,7 @@ def cert_to_xml(cert_doc):
            
     xml = render_template(dcc_template, doc=cert_doc['DCC'], utils=utils)  
     try:
-        xml = prettify_xml(xml, indent=2, debug=False)
+        xml = etree.canonicalize(prettify_xml(xml, indent=2, debug=False))
     except Exception as error:
         xml = '<error>' + str(error) + '</error>\n'
     
diff --git a/utils.py b/utils.py
index 9412ce5..84a7e70 100644
--- a/utils.py
+++ b/utils.py
@@ -68,7 +68,7 @@ ltx2entity = {
   '>':'&gt;'
 }
 
-def sanitize_ltx(x):
+def sanitize_ltx(x):# unnecessary, as done by canonicalize
     for key in ltx2entity:
         x = x.replace(key, ltx2entity[key])
     return x
-- 
GitLab