22 lines
668 B
Python
22 lines
668 B
Python
#!/usr/bin/env python3
|
|
"""Entferne problematischen CSRF-Error-Handler aus app.py"""
|
|
|
|
import re
|
|
|
|
# Lese die Backup-Datei
|
|
with open('app_backup.py', 'r', encoding='utf-8') as f:
|
|
content = f.read()
|
|
|
|
# Entferne den CSRF-Error-Handler-Block
|
|
# Suche nach @csrf.error_handler bis zum ersten leeren Zeilen-Block
|
|
pattern = r'@csrf\.error_handler.*?(?=\n\n|\n# [A-Z])'
|
|
content = re.sub(pattern, '', content, flags=re.DOTALL)
|
|
|
|
# Entferne auch mögliche doppelte Leerzeilen
|
|
content = re.sub(r'\n\n\n+', '\n\n', content)
|
|
|
|
# Schreibe die bereinigte Version
|
|
with open('app.py', 'w', encoding='utf-8') as f:
|
|
f.write(content)
|
|
|
|
print("CSRF-Error-Handler erfolgreich entfernt!") |