u01jmg3 / ics-parser

Parser for iCalendar Events • PHP 8+, 7 (≥ 7.4), 5 (≥ 5.6)
MIT License
448 stars 144 forks source link

Allowed memory size of 134217728 bytes exhausted (tried to allocate 20480 bytes) in Event.php line 198 #266

Closed nekromoff closed 4 years ago

nekromoff commented 4 years ago

After update from 2.6.16 to 2.6.19, issue #265 disappeared

Description of the Issue:

Allowed memory size of 134217728 bytes exhausted (tried to allocate 20480 bytes) in Event.php line 198

Steps to Reproduce:

Importing private URL

nekromoff commented 4 years ago

Maybe related to emojis or HTML entities?

u01jmg3 commented 4 years ago

Without ICS to test against I have no way of working out what the issue is. Obfuscate your data if required.

nekromoff commented 4 years ago

Any tips on how to debug this using break points (debug logs) in Event.php?

nekromoff commented 4 years ago

Maybe you will know more, I am doing print_r($key) in __construct:

MODIFIEDSEQUENCE_arraySEQUENCESTATUS_arraySTATUSSUMMARY_arraySUMMARYTRANSP_arrayTRANSPDTSTART_tzDTEND_tzDTSTART_arrayDTSTARTDTEND_arrayDTENDRRULE_arrayRRULEDTSTAMP_arrayDTSTAMPUID_arrayUIDCREATED_arrayCREATEDDESCRIPTION_arrayDESCRIPTIONLAST-MODIFIED_arrayLAST-MODIFIEDSEQUENCE_arraySEQUENCESTATUS_arraySTATUS 

(last STATUS is where it fails)

u01jmg3 commented 4 years ago

I'm going to need some formatting of your output...

u01jmg3 commented 4 years ago

The issue is related to the key part of the key/value pairs in your ICS

Is there data in your ICS file that doesn't look right such as something that isn't A-Z text such as symbols or such like?

nekromoff commented 4 years ago

Yeah, multiple characters in multiple events such as emojis ⚔️🛡️ or non-UTF8 characters for accepted invitations from (I suspect) external systems such as:

Súčasný  – aké nám
  bežia v \n\nü   – aký nastavený

Usually in SUMMARY or DESCRIPTION

u01jmg3 commented 4 years ago

Where did the ICS data come from? Looks like the encoding has gone awry which makes it extremely difficult to parse as things like newlines are not being represented correctly. This means I don't know where one line ends and another begins.

nekromoff commented 4 years ago

Google calendar, but old and it is possible that some characters are historically mangled. However, I have been using your library for over a year now without a glitch like this.

I have now tried to import a different time range and you are right, it passed with success. I am going to investigate further and report.

u01jmg3 commented 4 years ago

Yes please get back to me if you find out specifically what data is tripping things up.

Nothing has changed recently in Events.php - last edit made 6 months ago.

In the meantime I will see if I can harden the code to prevent memory issues.

u01jmg3 commented 4 years ago

One thing you could try is applying this function to this line in Event.php

u01jmg3 commented 4 years ago

@nekromoff: how are you getting on?

nekromoff commented 4 years ago

It was an external event, created by Microsoft calendar, but unfortunately the user deleted it so I can not debug it anymore. After the deletion, this issue has not appeared again.

cyberkeiler commented 3 years ago

Hi there. Have the same problem parsing customers ics Export of a google calendar. I'm pretty sure they used emojis or other special characters in their titles & descriptions. Is there any tipp to avoid this error yet? Any manual reformatting?

u01jmg3 commented 3 years ago

@cyberkeiler: as I said before in order to look at fixing this I would need the ICS causing the issue. I would suggest opening a new issue when you have isolated the relevant ICS.