git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v3] gitweb: redacted e-mail addresses feature.

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 21, 2021, 18:48 UTC
Message-ID
<xmqqv99k9wc9.fsf@gitster.g>
In-Reply-To
<87r1k8qs73.fsf@evledraar.gmail.com>
Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:
Show 33 quoted lines
> But:
>
>>  sub parse_tag {
>>  	my $tag_id = shift;
>>  	my %tag;
>> @@ -3471,6 +3493,10 @@ sub parse_tag {
>>  			if ($tag{'author'} =~ m/^([^<]+) <([^>]*)>/) {
>>  				$tag{'author_name'}  = $1;
>>  				$tag{'author_email'} = $2;
>> +				if (gitweb_check_feature('email_privacy')) {
>> +					$tag{'author_email'} = "private";
>> +					$tag{'author'} = hide_mailaddr($tag{'author'});
>> +				}
>
> This code seems quite awkward, we've already done the regex match, but
> this code:
>
>> [snip]
>> +sub hide_mailaddr_if_private {
>> +	my $line = shift;
>> +	return $line unless (gitweb_check_feature('email_privacy') &&
>> +						$line =~ m/^([^<]+) <([^>]*)>/);
>> +	return hide_mailaddr($line)
>> +}
>> +
>> +sub hide_mailaddr {
>> +	my $mailaddr = shift;
>> +	$mailaddr =~ s/<([^>]*)>/<private>/;
>> +	return $mailaddr;
>> +}
>
> Is going to do it again incrementally, and then just act on a
> search-replacement if we've got the feature enabled.

I think you misread the patch the same way as I did initially. What is called in parse_tag is not the "if-private" version---the caller knows that $tag{'author'} MUST BE an address so unconditionally redact when the feature is set by bypassing the _if_private variant.

Having said that, I do think
Show 6 quoted lines
>     sub maybe_hide_email {
>         my ($email, $ref) = shift;
>         return $email unless gitweb_check_feature('email_privacy');
>         $$ref = "private" if $ref;
>         return hide_email($email);
>     }
this helper is how you would simplify these numerous callers.
Show 19 quoted lines
>>  	} elsif ($format eq 'patch') {
>> -		local $/ = undef;
>> -		print <$fd>;
>> +		while (my $line = <$fd>) {
>> +			print hide_mailaddr_if_private($line);
>> +		}
>
> Urm, have you tested this? How does a while loop over a <$fd> make sense
> when $/ is undef, the readline() operator will always return just one
> record, so having a while loop doesn't make sense.
>
> I'm not sure of the input here, but given that if you're expecting to
> replace all e-mail addresses on all lines with this function that's not
> how it'll work, the s/// doesn't have a /g, so it'll stop at the first
> replacement.
>
>>  		close $fd
>>  			or print "Reading git-format-patch failed\n";
>>  	}

All true. This one is reading from "format-patch --stdout" output, but for the reasons I mentioned in my review, I do not think it should touch the 'patch' output at all.

Previous: Ævar Arnfjörð BjarmasonNext: Georgios Kontaxis
Message 8 of 41 in “gitweb: redacted e-mail addresses feature.”
  1. gitweb: redacted e-mail addresses feature.Georgios Kontaxis via GitGitGadget, Mar 20, 2021
  2. Ævar Arnfjörð BjarmasonMar 21, 2021
  3. brian m. carlsonMar 21, 2021
  4. Georgios KontaxisMar 21, 2021
  5. gitweb: redacted e-mail addresses feature.Georgios Kontaxis via GitGitGadget, Mar 21, 2021
  6. gitweb: redacted e-mail addresses feature.Georgios Kontaxis via GitGitGadget, Mar 21, 2021
  7. Ævar Arnfjörð BjarmasonMar 21, 2021
  8. Junio C HamanoMar 21, 2021
  9. Georgios KontaxisMar 21, 2021
  10. Junio C HamanoMar 21, 2021
  11. Junio C HamanoMar 21, 2021
  12. Junio C HamanoMar 21, 2021
  13. Georgios KontaxisMar 21, 2021
  14. Junio C HamanoMar 21, 2021
  15. Georgios KontaxisMar 21, 2021
  16. Junio C HamanoMar 22, 2021
  17. gitweb: redacted e-mail addresses feature.Georgios Kontaxis via GitGitGadget, Mar 22, 2021
  18. Junio C HamanoMar 22, 2021
  19. Georgios KontaxisMar 22, 2021
  20. Junio C HamanoMar 28, 2021
  21. Georgios KontaxisMar 28, 2021
  22. Junio C HamanoMar 28, 2021
  23. Georgios KontaxisMar 23, 2021
  24. gitweb: redacted e-mail addresses feature.Georgios Kontaxis via GitGitGadget, Mar 27, 2021
  25. gitweb: redacted e-mail addresses feature.Georgios Kontaxis via GitGitGadget, Mar 28, 2021
  26. Junio C HamanoMar 29, 2021
  27. Junio C HamanoMar 31, 2021
  28. Junio C HamanoApr 6, 2021
  29. Ævar Arnfjörð BjarmasonApr 8, 2021
  30. Junio C HamanoApr 8, 2021
  31. Eric WongMar 29, 2021
  32. Georgios KontaxisMar 29, 2021
  33. Eric WongApr 8, 2021
  34. Junio C HamanoApr 8, 2021
  35. Eric WongApr 8, 2021
  36. Ævar Arnfjörð BjarmasonApr 8, 2021
  37. Junio C HamanoApr 8, 2021
  38. Junio C HamanoMar 21, 2021
  39. Junio C HamanoMar 21, 2021
  40. Georgios KontaxisMar 21, 2021
  41. Junio C HamanoMar 21, 2021

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.