JM-Lemmi / ical-relay

Relay ical urls and edit them on the fly with different modules.
GNU Affero General Public License v3.0
9 stars 2 forks source link

Misplaced END:VCALENDAR #205

Closed JM-Lemmi closed 2 months ago

JM-Lemmi commented 9 months ago

history file includes a misplaced END:VCALENDAR somewhere in the middle, which leads to a parser error on the next history run.

broken files can be found like this:

for f in *.ics; do echo -n "$f "; cat "$f" | grep "END:VCALENDAR" | wc -l; done;

instead of BEGIN:VEVENT an END:VCALENDAR is placed in the middle somwhere

68,69c68,69
< BEGIN:VEVENT
< UID:20231220T080000-20231220T140000@egid.lp-parser.r110
---
> END:VCALENDAR
> ID:20231220T080000-20231220T140000@egid.lp-parser.r110

fehler scheint am 27.12. zw 5 uhr und 12 uhr aufgetreten zu sein

JM-Lemmi commented 9 months ago

grep -rn /etc/ical-relay/calstore -e '^ID:' findet den fehler auch

JM-Lemmi commented 9 months ago

grep -l -rn /etc/ical-relay/calstore -e '^ID:' <- all files with the error

sed -i 's/^ID:/UID:/' <- fix error

grep -l -rn /etc/ical-relay/calstore -e '^ID:' | xargs -I '{}' sed -i 's/^ID:/UID:/' {} <- all in one line

JM-Lemmi commented 9 months ago

END:VCALENDAR tritt am Ende der Timezone auf, mit dem ersten Event

image

JM-Lemmi commented 9 months ago

Fehler scheint erstmal nicht wieder aufgetreten zu sein. Möglicherweise ein einmaliger Fehler dank Out Of Memory?

robske110 commented 9 months ago

Closing this for now, most likely caused by a bad OOM crash of the server

JM-Lemmi commented 7 months ago

The issue persists.

JM-Lemmi commented 7 months ago

It looks to me, like the misplaced END:VCALENDAR is directly following END:VTIMEZONE. This element also seems wildly misplaced. Instead of the very beginning its somewhere in the middle.

root@j-bwc-cal:/home/debian# grep -rn /etc/ical-relay/calstore -e '^ID:'
/etc/ical-relay/calstore/TEL23D-past.ics:1451:ID:20231122T100555Z-384609001@group-e.dhbw-mannheim.de
/etc/ical-relay/calstore/TINF21CS1-past.ics:86:ID:20240320T090000Z-386958001@group-e.dhbw-mannheim.de
/etc/ical-relay/calstore/WWI23SCB-past.ics:799:ID:20240129T074346Z-390621001@group-e.dhbw-mannheim.de
JM-Lemmi commented 7 months ago

grep for all files, where END:VCALENDAR appears twice

for f in *.ics; do echo -n "$f "; cat "$f" | grep "END:VCALENDAR" | wc -l; done | grep " 2"

JM-Lemmi commented 7 months ago

replacing:

multiline sed or grep or awk is horrible, I couldnt do it. So here ismy other proposed fix:

we have a command that prints all the filenames, and we know that the first VCALENDAR is probably the wrong one, so we just match for that.

❗ this command is dangerous and might corrupt other files!

sed -i -z 's/END:VCALENDAR/BEGIN:VEVENT/' file.ics <- replace in place the first occurence of END:VCALENDAR mit BEGIN:VEVENT. dass er nur das erste matcht liegt an dem fehlenden G.

Sanity check: sed -z 's/END:VCALENDAR/BEGIN:VEVENT/' TEL23D-past.ics | grep END:VCALENDAR -A5 -B5 ohne -i printet das auf stdout und mit dem grep danach sehen wir, ob es am ende noch steht und sonst nicht mehr auftacuht, genau wie wir es haben wollen.

wir bekommen die Liste mit dateinamen mit dem wc hinten dran zum filtern, der muss also wieder weg: sed 's/..$//'

der command muss im richtigen ordner ausgeführt werden, da er keine absoluten pfade enthält

for f in *.ics; do echo -n "$f "; cat "$f" | grep "END:VCALENDAR" | wc -l; done | grep " 2" | sed 's/..$//' | xargs -I '{}' sed -i -z 's/END:VCALENDAR/BEGIN:VEVENT/' {}

JM-Lemmi commented 2 months ago

this seems to be an OOM error at some point. Not great, but more ram fixes it, so this will be a not-fix until it becomes relevant again.