如何在逐字稿草稿中遮蔽電郵地址而不宣稱匿名化
Mask email addresses in transcript drafts without claiming anonymization
文章提供一段本機預處理程式,以 [EMAIL] 取代常見 ASCII 電郵格式,並説明這只是便利篩選,不能視為私隱保證。匹配器會漏掉口述形式、國際化地址及其他特殊格式,也可能匹配到並非真實電郵地址的字串。文章建議保留原始資料於既有受限位置,另行在本機製作並檢查遮蔽稿,只分享重現問題所需的片段,並另外檢查其他識別資料。
Transcripts often contain contact details that should not appear in a public bug report. A local preprocessing step can remove obvious email-like strings before a developer shares a short reproduction. It should be described as a convenience filter, not a privacy guarantee.
Disclosure: I develop TokTranscript. This article was generated by an AI agent; the examples below were executed locally. The filter is an independent example and does not describe the service's privacy controls.
Start with a deliberately limited matcher
import re
EMAIL_LIKE = re.compile(
r"(?<![\w.+-])[A-Za-z0-9.!#$%&'*+/=?^_`{|}~-]+"
r"@[A-Za-z0-9](?:[A-Za-z0-9-]*[A-Za-z0-9])?"
r"(?:\.[A-Za-z0-9](?:[A-Za-z0-9-]*[A-Za-z0-9])?)+"
)
def mask_email_like(text):
return EMAIL_LIKE.sub("[EMAIL]", text)
assert mask_email_like("Email demo@example.org.") == "Email [EMAIL]."
assert mask_email_like("No contact details here") == "No contact details here"
assert mask_email_like("first.last+demo@example.org") == "[EMAIL]"
Understand the misses
The matcher intentionally covers a common ASCII form. It will miss spoken forms such as “demo at example dot org”, internationalized addresses and other unusual syntax. It can also match text that looks like an address but is not a real mailbox. A longer regular expression does not solve contextual privacy review.
Build a safe sharing workflow
Keep the original in its existing restricted location. Produce a separate redacted draft locally, review that exact draft, and share only the minimum passage required to reproduce the problem. Do not log the unredacted input while debugging the filter. Avoid putting names or source URLs into output filenames if those values are sensitive.
Review phone numbers, postal addresses, account identifiers, names and indirect identifiers separately. A combination of employer, date and job title can identify someone even after an email is removed. If timestamps are needed to reproduce a subtitle bug, keep only the relevant range.
This snippet changes text and nothing else. It does not remove metadata from attachments, redact the underlying recording, or demonstrate legal compliance. For sensitive recordings, use your organization's approved handling process rather than treating this small script as an anonymization system.
來源:DEV Community · dev.to