Re: [PATCH v4 2/6] t9001: check email address is in Cc: field

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Samuel GROOT <samuel.groot@xxxxxxxxxxxxxxxx> writes:

> Check if the given utf-8 email address is in the Cc: field.
>
> Signed-off-by: Tom RUSSELLO <tom.russello@xxxxxxxxxxxxxxxx>
> Signed-off-by: Samuel GROOT <samuel.groot@xxxxxxxxxxxxxxxx>
> Signed-off-by: Matthieu MOY <matthieu.moy@xxxxxxxxxxxxxxx>
> ---
>  t/t9001-send-email.sh | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh
> index 56ad8ce..943e6b7 100755
> --- a/t/t9001-send-email.sh
> +++ b/t/t9001-send-email.sh
> @@ -888,8 +888,8 @@ test_expect_success $PREREQ 'utf8 Cc is rfc2047 encoded' '
>  	--to=nobody@xxxxxxxxxxx \
>  	--smtp-server="$(pwd)/fake.sendmail" \
>  	outdir/*.patch &&
> -	grep "^	" msgtxt1 |
> -	grep "=?UTF-8?q?=C3=A0=C3=A9=C3=AC=C3=B6=C3=BA?= <utf8@xxxxxxxxxxx>"
> +	cc_adr=$(awk "/^Cc: /{flag=1}/^Subject: /{flag=0} flag {print}" msgtxt1) &&
> +	echo "$cc_adr" | fgrep "=?UTF-8?q?=C3=A0=C3=A9=C3=AC=C3=B6=C3=BA?= <utf8@xxxxxxxxxxx>"
>  '

This still depends on that the output has Cc: before Subject: and
there is no other header that can have an address on it.  E.g.

	To: a@xxxxxxxxxxx
        Cc: b@xxxxxxxxxxx
        X-foo: <<whatever address you are looking for>>
        Subject: [PATCH] A sample patch

would still say that the address is _on_ the CC: list.

I do not usually do awk, but I think you should be able to avoid
capturing output from it, echoing and then grepping, which is way
too ugly.  Perhaps you can start from something like below?

#!/bin/sh
awk '
	BEGIN { in_cc = 0 }
	/^[Cc][Cc]: / {
		sub("^[Cc][Cc]: *", "")
		in_cc = 1
	}
	/^[^ 	]*:/ {
		in_cc = 0
	}
	/^$/ { exit }
	in_cc {
		sub("^ *", "")
		sub(", *$", "")
		print
	}
' <<\EOF
To: a@xxxxxxxxxxx
Cc: b@xxxxxxxxxxx,
    c@xxxxxxxxxxx,
    d@xxxxxxxxxxx
X-foo: e@xxxxxxxxxxx
Subject: [PATCH] A sample patch

Cc: foo@xxxxxxxxxxx
EOF
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]