From a57790295c4ea72ff5e04997a6c6bd9bbede4df7 Mon Sep 17 00:00:00 2001 From: Lukas Geiger Date: Thu, 15 Oct 2026 18:36:29 +0200 Subject: [PATCH] fix(scanner): recognize HTML comment bang endings Author model: gpt-6.1-sol (Codex). Independent review pending. --- core/todo_scanner.py | 4 ++-- tests/test_todo_scanner.py | 26 ++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/core/todo_scanner.py b/core/todo_scanner.py index 962d124..cead2ff 100644 --- a/core/todo_scanner.py +++ b/core/todo_scanner.py @@ -102,8 +102,8 @@ def scan_file_for_todos( if allowed_tags and tag not in allowed_tags: continue - # Schließende Kommentarzeichen (*/ oder -->) am Zeilenende entfernen - text = re.sub(r'(\*/|-->)\s*$', '', raw_text).strip() + # Kommentar-Endzeichen für die Anzeige entfernen, kein HTML-Sanitizer. + text = re.sub(r'(\*/|--!?>)\s*$', '', raw_text).strip() items.append( TodoItem( diff --git a/tests/test_todo_scanner.py b/tests/test_todo_scanner.py index 1d95d5c..dfc70fa 100644 --- a/tests/test_todo_scanner.py +++ b/tests/test_todo_scanner.py @@ -90,6 +90,32 @@ def test_scan_file_for_todos(tmp_path): assert items[2].line_number == 5 +def test_scan_file_comment_terminators_preserve_task_text(tmp_path): + test_file = tmp_path / "comments.html" + test_file.write_text( + "\n" + " \n" + "/* BUG: C ending */\n" + "\n" + " inside text\n", + encoding="utf-8", + ) + + items = scan_file_for_todos(test_file) + assert [item.text for item in items] == [ + "Standard ending", + "Bang ending", + "C ending", + "Keep literal markup", + "Keep unsupported ending --!!>", + "Keep --> inside text", + ] + assert items[1].author == "anna" + assert items[1].line_number == 2 + assert items[1].line_text == " " + + def test_scan_file_binary_and_size_limits(tmp_path): """Prüft, dass Binärdateien und übergroße Dateien übersprungen werden.""" bin_file = tmp_path / "binary.dat"