[PATCH] Decode patch from UTF-8 while parsing from stdin
Dirk Wallenstein
halsmit at t-online.de
Thu Jan 13 19:49:42 EST 2011
On Mon, Dec 13, 2010 at 08:37:25AM +0800, Jeremy Kerr wrote:
> Hi Paul,
>
> > I think this patch needs to be reapplied, after the branch change(?) in
> > March 2010 [1].
>
> Thanks, good catch, I've reapplied it.
This does now decode twice and raises an exception (on both paths). I
don't see a reason for the second time, but attached is a patch that
makes it conditional.
Try it with this (the copyright sign will be decoded twice):
http://patchwork.freedesktop.org/patch/3648/
--
Greetings,
Dirk
-------------- next part --------------
>From 46ab3dfe76d5a7da05f4d0e84555e1ca9832fd59 Mon Sep 17 00:00:00 2001
From: Dirk Wallenstein <halsmit at t-online.de>
Date: Wed, 12 Jan 2011 19:39:23 +0100
Subject: [PATCH] Prevent repeated decoding in parse_patch
Signed-off-by: Dirk Wallenstein <halsmit at t-online.de>
---
apps/patchwork/parser.py | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/apps/patchwork/parser.py b/apps/patchwork/parser.py
index 24631b7..57b25c8 100644
--- a/apps/patchwork/parser.py
+++ b/apps/patchwork/parser.py
@@ -63,7 +63,10 @@ def parse_patch(text):
lc = (0, 0)
hunk = 0
- for line in text.decode('utf-8').split('\n'):
+ if not isinstance(text, unicode):
+ text = unicode(text, 'utf-8')
+
+ for line in text.split('\n'):
line += '\n'
if state == 0:
--
1.7.3.2
More information about the Patchwork
mailing list