]> git.ozlabs.org Git - patchwork/blobdiff - apps/patchwork/parser.py
models: fix From header in mbox view
[patchwork] / apps / patchwork / parser.py
index 16cc30851e6cc8f38e34cb0e66491cdd84bf347c..f4605668e67a78f9f7cbd1a5e4018251ba2caf17 100644 (file)
@@ -68,7 +68,7 @@ def parse_patch(text):
         line += '\n'
 
         if state == 0:
-            if line.startswith('diff') or line.startswith('===') \
+            if line.startswith('diff ') or line.startswith('===') \
                     or line.startswith('Index: '):
                 state = 1
                 buf += line
@@ -222,7 +222,10 @@ def main(args):
 
     (options, args) = parser.parse_args()
 
-    (patch, comment) = parse_patch(sys.stdin.read())
+    # decode from (assumed) UTF-8
+    content = sys.stdin.read().decode('utf-8')
+
+    (patch, comment) = parse_patch(content)
 
     if options.print_hash and patch:
         print hash_patch(patch).hexdigest()