diff --git a/scripts/personal_data_sources.py b/scripts/personal_data_sources.py index 4fa36da..5a0c9ee 100755 --- a/scripts/personal_data_sources.py +++ b/scripts/personal_data_sources.py @@ -28,6 +28,11 @@ REPO: Final = Path(__file__).resolve().parent.parent # popes, which is a cost worth paying to catch a real one. MIN_NAME: Final = 3 +# How much of a group id has to appear before it counts as that group. Eight +# base64 characters are 48 bits: unique enough that a coincidence is not +# worth worrying about, short enough to catch a truncated quotation. +PREFIX: Final = 8 + def _pack_names(directory: Path) -> set[str]: """Every trigger word in a photo pack manifest -- i.e. every name.""" @@ -104,6 +109,10 @@ def _database_groups(path: Path) -> set[str]: inner: set[str] = set() for group in found: payload = group.removeprefix("group.") + # The leading run as well as the whole id: a log line quoted into a + # commit message says "group...." and stops, and + # matching only the full id let exactly that through once. + inner.add(payload[:PREFIX]) try: inner.add(base64.b64decode(payload, validate=True).decode("utf-8")) except ValueError, UnicodeDecodeError: