mirror of
https://github.com/soxoj/maigret.git
synced 2026-09-22 17:54:55 +02:00
save_graph_report handed the file off to pyvis's show(), which opens it with open(name, "w+"), i.e. the locale encoding. On Windows that is the ANSI codepage (cp1252 by default), and the vis-network bundle pyvis inlines carries several hundred non-ASCII characters of its own, so every graph report died with UnicodeEncodeError regardless of what was scanned. The CLI aborted mid-run and left a 0-byte html file behind; the web interface builds a graph for every scan, so each one ended as "Search failed" and discarded the results. Render the html and write it here with encoding="utf-8" instead. The debug.log dump and the report template read had the same implicit encoding, so they get the same treatment. Three existing tests (test_build_reports_computes_found_count, test_real_report_generation_does_not_crash, test_live_scan_streams_found_and_done) fail on a non-utf-8 machine before this change and pass after it. The new tests perform the writes under -X warn_default_encoding, so a return to the implicit encoding fails on CI too, where the locale is utf-8 and the bug is invisible.