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

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

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 28, 2021, 01:41 UTC
Message-ID
<xmqqczvkoxzx.fsf@gitster.g>
In-Reply-To
<6f656f62497fb7c9322432b5eb151b86.squirrel@mail.kodaksys.org>
"Georgios Kontaxis" <geko1702+commits@99rst.org> writes:
Show 23 quoted lines
>> I'll defer to others who are more familiar with gitweb and Perl
>> ecosystem if this is warranted, but I have a feeling that importing
>> and using Mail::Address->parse() only because we want to see if a
>> given "<string>" is an address is a bit overkill and it might be
>> sufficient to do something as crude as m/^<[^@>]+@[a-z0-9-.]+>$/i
>> ...
>>> +	while ($line =~ m/(<[^>]+>)/g) {
>>> +		my $match = $1;
>>> +		if (!is_mailaddr($match)) {
>>> +			next;
>>> +		}
>>> +		my $offset = pos $line;
>>> +		my $head = substr $line, 0, $offset - length($match);
>>> +		my $redaction = "<redacted>";
>>> +		my $tail = substr $line, $offset;
>>> +		$line = $head . $redaction . $tail;
>>> +		pos $line = length($head) + length($redaction);
>>
>> Hmmmm, Perl suggestions from others?  It looks quite strange to see
>> that s/// operator is not used and replacement is done manually with
>> byte position in a Perl script.
>>
> If there's a more elegant way to do the above we can certain do that instead.

For example, if we do not insist on using overkill Mail::Address->parse(), we could do something silly like this:

	$line =~ s/<[^@>]+@[a-z0-9-.]+>/<redacted@address>/ig;
no?
Previous: Georgios KontaxisNext: Georgios Kontaxis
Message 20 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.