]> git.ozlabs.org Git - patchwork/blobdiff - apps/patchwork/parser.py
Add email opt-out system
[patchwork] / apps / patchwork / parser.py
index abec782f4f7c75cf74d7a83ef73b07f680addbdd..2b5e9a093c478756d65ef001cdb59e48eb0af0c5 100644 (file)
@@ -133,6 +133,9 @@ def parse_patch(text):
                 lc[0] -= 1
             elif line.startswith('+'):
                 lc[1] -= 1
+            elif line.startswith('\ No newline at end of file'):
+                # Special case: Not included as part of the hunk's line count
+                pass
             else:
                 lc[0] -= 1
                 lc[1] -= 1
@@ -219,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()