diff mbox

[v2,5/7] parser: subject_check needs to call clean_header

Message ID 1475040180-10770-6-git-send-email-dja@axtens.net
State Accepted
Headers show

Commit Message

Daniel Axtens Sept. 28, 2016, 5:22 a.m. UTC
When testing with headers with unencoded characters on Py3,
subject_check would fail. It was getting an Header class, rather
than a str/bytes, and so the regex was failing.

Run clean_header to decode everything fully first.

Signed-off-by: Daniel Axtens <dja@axtens.net>
---
 patchwork/parser.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Stephen Finucane Sept. 28, 2016, 5:10 p.m. UTC | #1
On 28 Sep 15:22, Daniel Axtens wrote:
> When testing with headers with unencoded characters on Py3,
> subject_check would fail. It was getting an Header class, rather
> than a str/bytes, and so the regex was failing.
> 
> Run clean_header to decode everything fully first.
> 
> Signed-off-by: Daniel Axtens <dja@axtens.net>

Good catch.

Reviewed-by: Stephen Finucane <stephen@that.guru>

> ---
>  patchwork/parser.py | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/patchwork/parser.py b/patchwork/parser.py
> index fbc36125c2ec..b0a841176aaf 100644
> --- a/patchwork/parser.py
> +++ b/patchwork/parser.py
> @@ -422,7 +422,7 @@ def subject_check(subject):
>      """Determine if a mail is a reply."""
>      comment_re = re.compile(r'^(re)[:\s]\s*', re.I)
>  
> -    return comment_re.match(subject)
> +    return comment_re.match(clean_header(subject))
>  
>  
>  def clean_content(content):
> -- 
> 2.7.4
>
Stephen Finucane Oct. 8, 2016, 12:16 p.m. UTC | #2
On 28 Sep 18:10, Stephen Finucane wrote:
> On 28 Sep 15:22, Daniel Axtens wrote:
> > When testing with headers with unencoded characters on Py3,
> > subject_check would fail. It was getting an Header class, rather
> > than a str/bytes, and so the regex was failing.
> > 
> > Run clean_header to decode everything fully first.
> > 
> > Signed-off-by: Daniel Axtens <dja@axtens.net>
> 
> Good catch.
> 
> Reviewed-by: Stephen Finucane <stephen@that.guru>

Applied.
diff mbox

Patch

diff --git a/patchwork/parser.py b/patchwork/parser.py
index fbc36125c2ec..b0a841176aaf 100644
--- a/patchwork/parser.py
+++ b/patchwork/parser.py
@@ -422,7 +422,7 @@  def subject_check(subject):
     """Determine if a mail is a reply."""
     comment_re = re.compile(r'^(re)[:\s]\s*', re.I)
 
-    return comment_re.match(subject)
+    return comment_re.match(clean_header(subject))
 
 
 def clean_content(content):