summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--_news_colors.py9
-rwxr-xr-xnews.py2
2 files changed, 8 insertions, 3 deletions
diff --git a/_news_colors.py b/_news_colors.py
index fd0782c..88bdc03 100644
--- a/_news_colors.py
+++ b/_news_colors.py
@@ -20,7 +20,12 @@
## You should have received a copy of the GNU General Public License
## along with this program. If not, see <http://www.gnu.org/licenses/>.
-import cgi
+try:
+ # py3
+ from html import escape as html_escape
+except ImportError:
+ # py2
+ from cgi import escape as html_escape
__all__ = ['make_html_colors_dict', 'make_txt_colors_dict', 'make_forum_colors_dict']
@@ -51,7 +56,7 @@ class HtmlDate(object):
class HtmlLink(object):
__slots__ = ()
def __format__(self, target):
- target = cgi.escape(target, True)
+ target = html_escape(target, True)
return '<a href="%s">%s</a>' % (target, target)
class HtmlSignature(object):
diff --git a/news.py b/news.py
index f5bbb52..531445a 100755
--- a/news.py
+++ b/news.py
@@ -124,7 +124,7 @@ class JSONWriter(BasicWriter):
entry, author = entry.rstrip('\n').rsplit('\n', 1)
self.stream.write('"title":"%s",' % title.format(**{'title':NOPFmt()})) # FIXME: assumes the first line is always the title
self.stream.write('"date":"%s",' % date.format(**{'date':NOPFmt()})) # FIXME: assumes the second line is always the date
- self.stream.write('"author":"%s",' % author.format(**{'author':NOPFmt()})) # FIXME: assumes the second line is always the date
+ self.stream.write('"author":"%s",' % author.format(**{'author':NOPFmt()})) # FIXME: assumes the last line is always the author
self.stream.write('"html":"')
entry = entry.lstrip('\n')
entry = entry.replace('\n\n', '<br/>')