# HG changeset patch # User neko259 # Date 2016-04-29 18:52:37 # Node ID ce9e0d38a638b6f1e31f7972c1accd9496aa74eb # Parent 135b5a86d65a033f64c8f841ff8578bfaac7f30e Convert \r\n and \r to \n in the post text used in sync diff --git a/boards/models/post/__init__.py b/boards/models/post/__init__.py --- a/boards/models/post/__init__.py +++ b/boards/models/post/__init__.py @@ -377,6 +377,7 @@ class Post(models.Model, Viewable): for key in replacements: text = text.replace('[post]{}[/post]'.format(key), '[post]{}[/post]'.format(replacements[key])) + text = text.replace('\r\n', '\n').replace('\r', '\n') return text diff --git a/boards/models/post/sync.py b/boards/models/post/sync.py --- a/boards/models/post/sync.py +++ b/boards/models/post/sync.py @@ -87,7 +87,7 @@ class SyncManager: signature = Signature( key_type=key.key_type, key=key.public_key, - signature=key.sign(et.tostring(content_tag, ENCODING_UNICODE)), + signature=key.sign(et.tostring(content_tag, encoding=ENCODING_UNICODE)), global_id=post.global_id, ) signature.save() diff --git a/boards/tests/test_sync.py b/boards/tests/test_sync.py --- a/boards/tests/test_sync.py +++ b/boards/tests/test_sync.py @@ -17,7 +17,8 @@ class SyncTest(TestCase): key = KeyPair.objects.generate_key(primary=True) tag = Tag.objects.create(name='tag1') - post = Post.objects.create_post(title='test_title', text='test_text', + post = Post.objects.create_post(title='test_title', + text='test_text\rline two', tags=[tag]) request = MockRequest() @@ -47,7 +48,7 @@ class SyncTest(TestCase): post.global_id.local_id, post.global_id.key_type, post.title, - post.get_raw_text(), + post.get_sync_text(), post.get_thread().get_tags().first().name, post.get_pub_time_str(), ) in response, @@ -94,7 +95,7 @@ class SyncTest(TestCase): post.global_id.local_id, post.global_id.key_type, post.title, - post.get_raw_text(), + post.get_sync_text(), post.get_thread().get_tags().first().name, post.get_pub_time_str(), ) in response,