From e3f6fec5f81fedcbeadb1fce51df15e03e03a395 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Dec 01 2016 14:11:35 +0000 Subject: Fix blaming files containing non-ascii characters The error was reported by email on a certain file of the linux kernel repo that is also present in staging. The added unit-test allows to replicate the issue and the fix of the filter actually fixes it. --- diff --git a/pagure/ui/filters.py b/pagure/ui/filters.py index 45f32f6..478e080 100644 --- a/pagure/ui/filters.py +++ b/pagure/ui/filters.py @@ -268,6 +268,8 @@ def blame_loc(loc, repo, username, blame): ] for idx, line in enumerate(loc.split('\n')): + line = line.decode('utf-8') + if line == '': break diff --git a/tests/test_pagure_flask_ui_repo.py b/tests/test_pagure_flask_ui_repo.py index edc5322..1079b22 100644 --- a/tests/test_pagure_flask_ui_repo.py +++ b/tests/test_pagure_flask_ui_repo.py @@ -1701,6 +1701,9 @@ class PagureFlaskRepotests(tests.Modeltests): tests.add_commit_git_repo( os.path.join(self.path, 'forks', 'pingou', 'test3.git'), ncommits=10) + tests.add_content_to_git( + os.path.join(self.path, 'forks', 'pingou', 'test3.git'), + content='foö\bbáßðáz') output = self.app.get('/fork/pingou/test3/blame/sources') self.assertEqual(output.status_code, 200)