Skip to content
This repository has been archived by the owner on Oct 4, 2020. It is now read-only.

Commit

Permalink
Unicode characters fix
Browse files Browse the repository at this point in the history
  • Loading branch information
gherynos committed Mar 19, 2017
1 parent 1edea19 commit c3ae87f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
14 changes: 9 additions & 5 deletions app/controllers/feeds.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Copyright (C) 2012-2016 Luca Zanconato (<luca.zanconato@nharyes.net>)
Copyright (C) 2012-2017 Luca Zanconato (<luca.zanconato@nharyes.net>)
This file is part of Plus Channel.
Expand Down Expand Up @@ -58,7 +58,11 @@ def create(self, mc, db):
@route('/feeds/<pkey>', method=['GET'])
def get(self, mc, db, pkey):
def check_encoding(string):
return ud.normalize('NFKD', string).encode('ascii', 'xmlcharrefreplace')
data = string
if string is not unicode:
data = unicode(string)

return ud.normalize('NFKD', data).encode('ascii', 'xmlcharrefreplace')

try:
# host URL
Expand All @@ -76,13 +80,13 @@ def check_encoding(string):
channel.title('Plus Channel feed')
channel.description('Google+ List of Activities for %s' % obj['name'])
channel.generator('Plus Channel %s' % cfg.get('main.version'))
channel.id('http://plus.google.com/' + user_id)
channel.id('https://plus.google.com/' + user_id)
channel.link(href=host_url, rel='self')
channel.docs('')
if 'photo_url' in obj and obj['photo_url'] is not None:
channel.image(url=obj['photo_url'],
title='Plus Channel feed',
link='http://plus.google.com/' + user_id,
link='https://plus.google.com/' + user_id,
width=str(cfg.get('feed.photo_size.database')),
height=str(cfg.get('feed.photo_size.database')))

Expand Down Expand Up @@ -153,7 +157,7 @@ def check_encoding(string):

# return created feed
response.set_header('content-type', 'application/rss+xml; charset=utf-8')
out = unicode(channel.rss_str(pretty=True))
out = channel.rss_str(pretty=True)
del channel, activities, user_id, obj
return out

Expand Down
4 changes: 2 additions & 2 deletions app/services/feed_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def get_random_key():
feed.save(db)

else:
mc.delete(cls.MEMCACHE_KEY % feed.pkey)
mc.delete(str(cls.MEMCACHE_KEY % feed.pkey))

# update photo
feed.photo_url = photo_url_db
Expand Down Expand Up @@ -152,7 +152,7 @@ def process_activity_data(atv):
atv['url'] = url

# check memcache for existing value
m_key = cls.MEMCACHE_KEY % pkey
m_key = str(cls.MEMCACHE_KEY % pkey)
feed = mc.get(m_key)
if not feed:
# load feed from DB
Expand Down

0 comments on commit c3ae87f

Please sign in to comment.