From f2056d0a59cd7234610dd7da1ea2c3e2a4be0f00 Mon Sep 17 00:00:00 2001 From: Christoph Schlosser Date: Thu, 18 Sep 2025 20:56:26 +0200 Subject: g2h: Use a different kind of email redaction A bug in hugo, or it's markdown renderer shouldn't prevent using a more typical pattern. --- g2h/commit_page.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'g2h/commit_page.py') diff --git a/g2h/commit_page.py b/g2h/commit_page.py index a998417..03d74ab 100644 --- a/g2h/commit_page.py +++ b/g2h/commit_page.py @@ -2,18 +2,24 @@ import os from .page import Page +def _redact_local_segment(local_segment): + if len(local_segment) == 0: + return '' + if len(local_segment) < 6: + return local_segment[0] + '...' + return local_segment[:2] + '...' + def redact_email(email): if email is None or len(email) == 0: return '' if '@' not in email: - return email[0] + '...' + email[-1] + return _redact_local_segment(email) local, domain = email.split('@') - redacted_local = local[0] + '...' + local[-1] if len(local) > 0 else '' - redacted_domain = domain.replace('.', '...') + redacted_local = _redact_local_segment(local) - return redacted_local + '@' + redacted_domain + return redacted_local + '@' + domain class CommitPage(Page): def __init__(self, out_dir, name, commit, content_subdir): -- cgit v1.2.3