From b2f7a7967a970ac9fe8cfd7d377c349f46e17efd Mon Sep 17 00:00:00 2001
From: Marco Malavolti <marco.malavolti@gmail.com>
Date: Fri, 3 Jul 2020 03:45:55 +0200
Subject: [PATCH] Fixed a problem with IdP displayName with quotes

---
 api.py   |  1 +
 eccs2.py | 10 +++++-----
 utils.py |  4 ++--
 3 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/api.py b/api.py
index c6b451e..30a8000 100755
--- a/api.py
+++ b/api.py
@@ -61,6 +61,7 @@ class EccsResults(Resource):
        for line in lines:
           # Strip the line feed and carriage return characters
           line = line.rstrip("\n\r")
+          print(line)
 
           # Loads the json line into aux
           aux = json.loads(line)
diff --git a/eccs2.py b/eccs2.py
index ad79537..12c3b10 100755
--- a/eccs2.py
+++ b/eccs2.py
@@ -97,7 +97,7 @@ def checkIdP(sp,idp,test):
      return (idp['entityID'],wayfless_url,check_time,"(failed)","Timeout")
 
    except Exception as e:
-     print ("!!! EXCEPTION !!!")
+     print ("!!! EXCEPTION DRIVER !!!")
      print (e.__str__())
      print ("IdP: %s\nSP: %s" % (idp['entityID'],sp))
      return None
@@ -143,7 +143,7 @@ def checkIdP(sp,idp,test):
      status_code = "333"
 
    except Exception as e:
-     print ("!!! EXCEPTION !!!")
+     print ("!!! EXCEPTION REQUESTS !!!")
      print (e.__str__())
      print ("IdP: %s\nSP: %s" % (idp['entityID'],sp))
      status_code = "555"
@@ -161,10 +161,10 @@ def getDisplayName(display_name):
     display_name_equal_splitted = display_name.split('==')
     for elem in display_name_equal_splitted:
         if "en" in elem:
-           if "&apos;" in elem:
-               elem = elem.replace("&apos;","'")
            if "&#039;" in elem:
-               elem = elem.replace("&#039;","'")
+              elem = elem.replace("&#039;","'")
+           if '"' in elem:
+              elem = elem.replace('"','\\"')
            return elem.split(';')[1]
 
 
diff --git a/utils.py b/utils.py
index 4424355..03604e9 100644
--- a/utils.py
+++ b/utils.py
@@ -50,7 +50,7 @@ def getListFeds(url, dest_file):
 
     # then open it and work with local file
     with open("%s" % (dest_file), mode="r", encoding='utf-8') as f:
-         return json.loads(f.read().replace("'", "&apos;"))
+         return json.loads(f.read().replace("'","&#039;"))
 
 
 # Download all eduGAIN IdPs from URL, store them on a local file and returns a Python List
@@ -63,7 +63,7 @@ def getListEccsIdps(url, dest_file):
 
     # then open it and work with local file
     with open("%s" % (dest_file), mode="r", encoding='utf-8') as f:
-         return json.loads(f.read().replace("'", "&apos;"))
+         return json.loads(f.read().replace("'","&#039;"))
 
 
 # Use logger to produce files consumed by ECCS-2 API
-- 
GitLab