aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJordan <me@jordan.im>2020-06-16 18:24:04 -0700
committerJordan <me@jordan.im>2020-06-16 18:24:04 -0700
commitb9d9ce7c7488ea1789ef3b31eb5a0c4e7a2eddb2 (patch)
treee4d887c485d8dcfb36fedc0f4d314593123f996f
parentdb9c587be13eaab1aa83d5fb277dde39c807d393 (diff)
downloadroka-b9d9ce7c7488ea1789ef3b31eb5a0c4e7a2eddb2.tar.gz
roka-b9d9ce7c7488ea1789ef3b31eb5a0c4e7a2eddb2.zip
rm prettify, correct quote/apos escape
-rw-r--r--lib/util.py13
-rwxr-xr-xrun.py4
2 files changed, 5 insertions, 12 deletions
diff --git a/lib/util.py b/lib/util.py
index 74d795d..ac1c904 100644
--- a/lib/util.py
+++ b/lib/util.py
@@ -43,7 +43,8 @@ def escape(s):
s = s.replace('&', '&amp;')
s = s.replace('<', '&lt;')
s = s.replace('>', '&gt;')
- s = s.replace('\'', '&quot;')
+ s = s.replace('\'', '&apos;')
+ s = s.replace('\"', '&quot;')
# https://stackoverflow.com/a/22273639
illegal_unichrs = [
@@ -77,14 +78,6 @@ def escape(s):
return s
-def prettify(elem):
- '''
- Make our RSS feed picturesque :)
- '''
- xml_str = ET.tostring(elem, encoding='utf8', method='xml')
- xml_dom = minidom.parseString(xml_str)
- return xml_dom.toprettyxml(indent=' ')
-
def generate_rss(request, books):
book = request.args.get('a') # audiobook hash
@@ -168,5 +161,5 @@ def generate_rss(request, books):
}
ET.SubElement(item, 'enclosure', enc_attr)
- return rss
+ return ET.tostring(rss, encoding='utf8', method='xml')
diff --git a/run.py b/run.py
index f9c70d3..8cedd8d 100755
--- a/run.py
+++ b/run.py
@@ -3,7 +3,7 @@
import os
from flask import Flask, request, Response, render_template, send_file
from flask import send_from_directory
-from lib.util import check_auth, escape, generate_rss, prettify, read_cache
+from lib.util import check_auth, escape, generate_rss, read_cache
abs_path = os.path.dirname(os.path.abspath(__file__))
app = Flask(__name__)
@@ -41,7 +41,7 @@ def list_books():
return 'book not found', 404
rss = generate_rss(request, books)
- return Response(prettify(rss), mimetype='text/xml')
+ return Response(rss, mimetype='text/xml')
else:
auth = request.authorization
if not auth or not check_auth(app, auth.username, auth.password):