fix: CSV- und XML-Export als gueltige, Excel-taugliche Dateien#19
Merged
Conversation
CSV war in (dt.) Excel unbrauchbar (alles in Spalte A, mehrzeiliger Inhalt zerfaellt, Mojibake); XML war nicht wohlgeformt bei &/</> oder ]]> im Inhalt. CSV: - Schreibweg utf-8-sig (BOM) + newline="" statt write_text → behebt korrupte \r\r\n-Zeilenenden und Mojibake in dt. Excel - Trennzeichen Semikolon (dt. Excel splittet beim Doppelklick auf ;) - Formula-Injection-Schutz (fuehrendes ' bei =,+,-,@) + Steuerzeichen-Filter (Felder stammen aus fremden Seiten) XML: - _render_xml defensiv: Steuerzeichen filtern, Titel/URL XML-escapen, Content in CDATA per ]]>-Neutralisierung absichern; CDATA-Template bleibt erhalten (robust auch fuer Custom-Templates) - einmalige re.sub-Ersetzung statt blindem _apply_template → kein Escaping-Bypass/Platzhalter-Injection Migration/Defaults: - _default_formats + Format-Editor-Defaults auf ; - einmalige, versionsgeflaggte Migration (formats_rev) hebt altes Komma der Bestandsnutzer auf ; an, ohne spaetere bewusste Editor-Wahl zu ueberschreiben Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Bei CSV-/XML-Ausgabe meldete das Protokoll irrefuehrend 'Konvertiere Inhalt zu Markdown'. Die Meldung nennt jetzt das gewaehlte Zielformat. Nebenbei doppelte fmt/fmt_type-Berechnung entfernt. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Eine im CSV-Format erzeugte Datei war in (deutschem) Excel unbrauchbar: alles in Spalte A, der mehrzeilige Markdown-Inhalt zerfiel über viele Zeilen, Umlaute/Emojis als Mojibake (
für,â€",ðŸ'¡). Das XML-Format war nicht wohlgeformt, sobald Felder&/</>oder die Sequenz]]>enthielten.Ursachen & Fixes
CSV
Scraper.runschrieb viawrite_text(Textmodus) →csv.writer-\r\nwurde zu\r\r\n, Excels Quote-Parsing brach. → Schreiben jetzt mitopen(..., encoding="utf-8-sig", newline="")(BOM + keine Newline-Übersetzung).;. → Default;.=/+/-/@→ Excel-Formel; QUOTE_ALL schützt nicht) → führendes'. Plus C0-Steuerzeichen-Filter.XML
_render_xmldefensiv: Steuerzeichen filtern (sonst nicht wohlgeformt –escape()entfernt sie nicht), Titel/URL XML-escapen, Content in CDATA per]]>-Neutralisierung absichern. CDATA-Template bleibt erhalten → robust auch für Custom-Templates, keine Migration nötig. Einmaligere.sub-Ersetzung statt blindem_apply_template(kein Escaping-Bypass/Platzhalter-Injection).Defaults/Migration
_default_formats+ Format-Editor-Defaults auf;.formats_rev) hebt das alte Komma der Bestandsnutzer auf;an – ohne eine spätere bewusste Editor-Wahl zu überschreiben (läuft genau einmal, nicht im Hot-Path).Bewusste Grenzen
Semikolon-Doppelklick hängt vom Windows-Listentrennzeichen ab (dt. Standard
;);contentbleibt voller Markdown (eine Zelle; Excel-Zell-Limit 32.767 Zeichen → nur Anzeige gekürzt, Datei vollständig).Verifikation (per Import-Tests gegen die echten Funktionen)
\r\r\n,;-Spalten (Header+1 Zeile), Formula-Schutz ('=…), NUL entfernt, content = eine mehrzeilige Zelle inkl.;/".ET.parsewohlgeformt,]]>-Roundtrip,&escaped, Steuerzeichen gefiltert.,→;, Flag gesetzt; zweiter Lauf respektiert spätere,-Wahl. Echte Nutzer-Settings im Test gemockt (unberührt).py_compileok.Geprüft in zwei Runden durch je 10 Fach-Agenten.
🤖 Generated with Claude Code