(2020-10-29, 02:13)matthuisman Wrote: looking at the source - as far as I can tell - there is no xml escaping being done.
So if a program had any special xml characters (eg. < or > or ") in it's information, then the XML would become invalid.
@d21spike just need to do
python:
from xml.sax.saxutils import escape
prg += ' <title lang="en">%s</title>\n' % escape(title)
(same for subtitle, description etc)
Hi, I just registered on the forum for this post. I looked at the guide.xml with xmllint and it spotted a bunch of unescaped '&' so I followed your suggestion to escape strings in the guide.py file.
My Sling guide is now producing properly escaped xml and Kodi's TV guide is back to normal. Included is the patch (sorry, no GitHub account) to addons/plugin.video.sling/resources/lib/service.
Be sure to backup your guide.py, you know, just in case. Restarting kodi may be required.
Thanks for the clue!
diff:
--- guide.py.orig 2020-05-21 05:46:04.000000000 -0400
+++ guide.py 2020-10-28 22:47:46.000000000 -0400
@@ -1,5 +1,6 @@
from resources.lib.globals import *
from resources.lib.classes.auth import Auth
+from xml.sax.saxutils import escape
if sys.version_info.major == 2:
from SimpleHTTPServer import SimpleHTTPRequestHandler
@@ -135,8 +136,8 @@
channels = self.getChannels()
for channel_id, title, logo, url, genre in channels:
- channel = '<channel id="%s">\n' % channel_id
- channel += ' <display-name lang="en">%s</display-name>\n' % title
+ channel = '<channel id="%s">\n' % escape(channel_id)
+ channel += ' <display-name lang="en">%s</display-name>\n' % escape(title)
channel += '</channel>\n'
html.write(channel.encode())
@@ -167,11 +168,11 @@
prg = ''
prg += '<programme start="%s" stop="%s" channel="%s">\n' % (start_time, stop_time, channel_id)
- prg += ' <title lang="en">%s</title>\n' % title
- prg += ' <sub-title lang="en">%s</sub-title>\n' % sub_title
- prg += ' <desc lang="en">%s</desc>\n' % desc
+ prg += ' <title lang="en">%s</title>\n' % escape(title)
+ prg += ' <sub-title lang="en">%s</sub-title>\n' % escape(sub_title)
+ prg += ' <desc lang="en">%s</desc>\n' % escape(desc)
for genre in genres:
- prg += ' <category lang="en">%s</category>\n' % str(strip(genre)).strip().capitalize()
+ prg += ' <category lang="en">%s</category>\n' % escape(str(strip(genre)).strip().capitalize())
prg += ' <icon src="%s"/>\n' % icon
prg += '</programme>\n'