From b3b33c902a7eb9fa17473ce018da802eafdce5d1 Mon Sep 17 00:00:00 2001
From: Filip Gurbal <filip.gurbal@adaptiware.com>
Date: Mon, 4 Nov 2019 11:30:54 +0100
Subject: [PATCH 1/2] Fix libraries sync when jellyfin library has apostrophes
 in name

---
 resources/lib/helper/utils.py | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/resources/lib/helper/utils.py b/resources/lib/helper/utils.py
index 95c99c7c..19411b1b 100644
--- a/resources/lib/helper/utils.py
+++ b/resources/lib/helper/utils.py
@@ -293,7 +293,11 @@ def indent(elem, level=0):
 def write_xml(content, file):
     with open(file, 'w') as infile:
 
-        content = content.replace("'", '"')
+        def replace_apostrophes(match):
+            return match.group(0).replace("'", '"')
+
+        content = re.sub("<(.*?)>", replace_apostrophes, content)
+
         content = content.replace('?>', ' standalone="yes" ?>', 1)
         infile.write(content)
 

From 989ff6d36771e4441ffed2c2883ae694af20b0b6 Mon Sep 17 00:00:00 2001
From: Filip Gurbal <filip.gurbal@adaptiware.com>
Date: Mon, 4 Nov 2019 14:04:50 +0100
Subject: [PATCH 2/2] Added comment for replace_apostrophes function in
 write_xml

---
 resources/lib/helper/utils.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/resources/lib/helper/utils.py b/resources/lib/helper/utils.py
index 19411b1b..058349c1 100644
--- a/resources/lib/helper/utils.py
+++ b/resources/lib/helper/utils.py
@@ -293,9 +293,9 @@ def indent(elem, level=0):
 def write_xml(content, file):
     with open(file, 'w') as infile:
 
+        # replace apostrophes with double quotes only in xml keys, not texts
         def replace_apostrophes(match):
             return match.group(0).replace("'", '"')
-
         content = re.sub("<(.*?)>", replace_apostrophes, content)
 
         content = content.replace('?>', ' standalone="yes" ?>', 1)