Whole file
cyberjunky/python-garminconnect
The author described this change as “security: fix exercise-catalog text accumulation and final-item flush”. It counts as a record because the check below fails on the code as it stood at a51330b8e and passes on 764ddfa55, with nothing else changed between the two runs.
Fix saved2026-08-10
Sharing licenceMIT · LICENSE
Change size+9 −1
What the code was meant to do, written into the code itself as a save note
security: fix exercise-catalog text accumulation and final-item flush
The change
| 56 | 56 | self._in_span = True | |
| 57 | 57 | ||
| 58 | 58 | def handle_data(self, data: str) -> None: | |
| 59 | + | # A nested tag inside the span (e.g. <b>) triggers another | |
| 60 | + | # handle_data call for its own text; accumulate rather than | |
| 61 | + | # overwrite, or a fragment like the "https://" prefix of a stray | |
| 62 | + | # URL is dropped and the SUSPECT filter never sees it. | |
| 59 | 63 | if self._in_span and self._cur is not None: | |
| 60 | - | self._cur[2] = data.strip() | |
| 64 | + | self._cur[2] = (self._cur[2] or "") + data | |
| 61 | 65 | ||
| 62 | 66 | def handle_endtag(self, tag: str) -> None: | |
| 63 | 67 | if tag == "span": | |
| ⋯ | |||
| 90 | 94 | parser = _PickerParser() | |
| 91 | 95 | parser.feed(text) | |
| 92 | 96 | parser.close() | |
| 97 | + | # HTMLParser.close() doesn't synthesize a missing </li>, so the last | |
| 98 | + | # item (if the source HTML omits its closing tag) needs an explicit | |
| 99 | + | # flush here. | |
| 100 | + | parser._flush() | |
| 93 | 101 | seen: set[tuple[str, str]] = set() | |
| 94 | 102 | out: list[dict[str, str]] = [] | |
| 95 | 103 | for category, exercise, name in parser.rows: | |
The check that tells the two apart
fail→pass·tests/test_generate_exercises.py::test_parse_accumulates_text_across_nested_tags
Check file tests/test_generate_exercises.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.
Origin and history
The code before ita51330b8e462c1855a5b9b2112d79e668e0e49ed
Broken version dated2026-08-10
Modulescripts.generate_exercises
Units changed_PickerParser, parse
Fingerprint1dfd0c385db3eae7
Checked2026-08-18 by goldset/0.1
Every field above is generated by our program. None of it is written by hand.