diff src/server/blog.py @ 726:e949b7c7ed9c

server side (blog): fixes unicode error
author souliane <souliane@mailoo.org>
date Mon, 21 Sep 2015 12:01:34 +0200
parents c1abaa91a121
children 3bd097380da7
line wrap: on
line diff
--- a/src/server/blog.py	Thu Sep 10 15:17:18 2015 +0200
+++ b/src/server/blog.py	Mon Sep 21 12:01:34 2015 +0200
@@ -351,16 +351,16 @@
         """
         if not isinstance(options, dict):
             options = {}
-        user = sanitizeHtml(profile).encode('utf-8')
+        user = sanitizeHtml(profile)
         root_url = '../' * len(request.postpath)
         base_url = root_url + 'blog/' + user
 
         def getOption(key):
-            return sanitizeHtml(options[key]).encode('utf-8') if key in options else ''
+            return sanitizeHtml(options[key]) if key in options else ''
 
         def getImageParams(key, default, alt):
             """regexp from http://answers.oreilly.com/topic/280-how-to-validate-urls-with-regular-expressions/"""
-            url = options[key].encode('utf-8') if key in options else ''
+            url = options[key] if key in options else ''
             regexp = r"^(https?|ftp)://[a-z0-9-]+(\.[a-z0-9-]+)+(/[\w-]+)*/[\w-]+\.(gif|png|jpg)$"
             if re.match(regexp, url):
                 url = url
@@ -481,10 +481,10 @@
         self.content = self.getText(entry, 'content')
 
         if is_comment:
-            self.author = (_("from %s") % entry['author']).encode('utf-8')
+            self.author = (_("from %s") % entry['author'])
         else:
             self.author = '&nbsp;'
-            self.url = (u"%s/%s" % (base_url, entry['id'])).encode('utf-8')
+            self.url = (u"%s/%s" % (base_url, entry['id']))
             self.title = self.getText(entry, 'title')
 
             count_text = lambda count: D_('comments') if count > 1 else D_('comment')
@@ -504,8 +504,8 @@
 
     def getText(self, entry, key):
         if ('%s_xhtml' % key) in entry:
-            return entry['%s_xhtml' % key].encode('utf-8')
+            return entry['%s_xhtml' % key]
         elif key in entry:
             processor = addURLToText if key.startswith('content') else sanitizeHtml
-            return convertNewLinesToXHTML(processor(entry[key])).encode('utf-8')
+            return convertNewLinesToXHTML(processor(entry[key]))
         return None