Files
breakpilot-compliance/backend-compliance/compliance/tests/test_impressum_line_of.py
T
Benjamin Admin 877d540ce1 fix(cookie+impressum): Drittland-FP, Impressum-Beleg, neuer Opt-Out-Finding
- Drittland: unbekannte Herkunft ('N/A') + Self-Hosting feuern nicht mehr —
  First-Party-Session-Cookies (PHPSESSID/JSESSIONID) waren False Positives.
- Impressum _line_of: enges Fenster um den Treffer bei Texten ohne Umbrüche
  (BMW = ein Block) → jede Pflichtangabe zeigt IHREN Beleg statt denselben Satz.
- Neuer Finding-Typ missing_opt_out: einwilligungspflichtiger Anbieter mit
  Cookies ohne Opt-Out-/Widerspruchs-Link (Art. 7 Abs. 3 + Art. 21).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-11 11:59:48 +02:00

30 lines
1.1 KiB
Python

"""_line_of — Beleg-Ausschnitt pro Pflichtangabe.
Regression: bei Impressum-Texten ohne Zeilenumbrüche (z.B. BMW als ein Block)
zeigte die Pflichtangaben-Tabelle für JEDE MC denselben Anfangssatz. Jetzt wird
ein enges Fenster um den Treffer ausgeschnitten → jede MC zeigt ihren Beleg.
"""
from __future__ import annotations
from compliance.services.specialist_agents.impressum.agent import _line_of
def test_window_per_match_in_long_block():
text = "A" * 200 + " EMAIL kontakt@bmw.de " + "B" * 200 + " HRB 12345 " + "C" * 200
e_pos = text.index("kontakt@bmw.de")
h_pos = text.index("12345")
email = _line_of(text, e_pos, e_pos + len("kontakt@bmw.de"))
hrb = _line_of(text, h_pos, h_pos + 5)
assert "kontakt@bmw.de" in email
assert "12345" in hrb
assert email != hrb # nicht mehr derselbe Anfangssatz
assert len(email) <= 160
def test_short_line_unchanged():
text = "Zeile eins\nkontakt@bmw.de\nZeile drei"
pos = text.index("kontakt@bmw.de")
out = _line_of(text, pos, pos + len("kontakt@bmw.de"))
assert out == "kontakt@bmw.de"