diff --git a/pagure/ui/filters.py b/pagure/ui/filters.py
index 478e080..1226d22 100644
--- a/pagure/ui/filters.py
+++ b/pagure/ui/filters.py
@@ -20,6 +20,7 @@ import urlparse
import arrow
import flask
import md5
+import six
from pygments import highlight
from pygments.lexers.text import DiffLexer
@@ -250,7 +251,7 @@ def blame_loc(loc, repo, username, blame):
and convert it into a html table displayed to the user with the git
blame information (user, commit, commit date).
- :arg loc: a text object of the lines of code to display (in this case,
+ :arg loc: a unicode object of the lines of code to display (in this case,
most likely the content of a file).
:arg repo: the name of the repo in which this file is.
:arg username: the user name of the user whose repo this is, if the repo
@@ -262,14 +263,15 @@ def blame_loc(loc, repo, username, blame):
if loc is None:
return
+ if not isinstance(loc, six.text_type):
+ raise ValueError('"loc" must be a unicode string, not ' + str(type(loc)))
+
output = [
'
',
'
'
]
for idx, line in enumerate(loc.split('\n')):
- line = line.decode('utf-8')
-
if line == '':
break
diff --git a/pagure/ui/repo.py b/pagure/ui/repo.py
index b22e5df..096aa97 100644
--- a/pagure/ui/repo.py
+++ b/pagure/ui/repo.py
@@ -708,7 +708,7 @@ def view_blame_file(repo, filename, username=None, namespace=None):
if is_binary_string(content.data):
flask.abort(400, 'Binary files cannot be blamed')
- content = ktc.to_bytes(content.data)
+ content = encoding_utils.decode(content.data)
blame = repo_obj.blame(filename)
return flask.render_template(
diff --git a/tests/test_pagure_flask_ui_repo.py b/tests/test_pagure_flask_ui_repo.py
index 1079b22..9a2d9ae 100644
--- a/tests/test_pagure_flask_ui_repo.py
+++ b/tests/test_pagure_flask_ui_repo.py
@@ -1637,7 +1637,7 @@ class PagureFlaskRepotests(tests.Modeltests):
self.assertIn(b'', output.data)
self.assertIn(
b' | ', output.data)
+ b'data-line-number="1">', output.data)
self.assertIn(
b' bar | ', output.data)
@@ -1703,7 +1703,7 @@ class PagureFlaskRepotests(tests.Modeltests):
ncommits=10)
tests.add_content_to_git(
os.path.join(self.path, 'forks', 'pingou', 'test3.git'),
- content='foö\bbáßðáz')
+ content=u'✨☃🍰☃✨'.encode('utf-8'))
output = self.app.get('/fork/pingou/test3/blame/sources')
self.assertEqual(output.status_code, 200)