Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Undefined array key warning if DESCRIPTION contains HTML ampersand entities #317

Closed
room34 opened this issue Mar 6, 2023 · 5 comments
Closed

Comments

@room34
Copy link
Contributor

room34 commented Mar 6, 2023

  • PHP Version: 8.1.2
  • PHP date.timezone: America/Chicago
  • ICS Parser Version: 3.2.1
  • Linux

Description of the Issue:

If the .ics file contains an ampersand entity in the DESCRIPTION (though I suspect the issue may just be the semicolon), I get the following PHP warnings:

Warning: Undefined array key 4 in /var/www/.../ics-parser/src/ICal/ICal.php on line 1033

Warning: Undefined array key 4 in /var/www/.../ics-parser/src/ICal/ICal.php on line 1042

(The attached file has a .txt extension appended so GitHub will accept the upload.)
AmpersandEntityExample.ics.txt

Steps to Reproduce:

Use attached example which contains an HTML ampersand entity in the DESCRIPTION. This is an actual example from one of my users, with all events other than the one containing the ampersand entity removed.

@u01jmg3
Copy link
Owner

u01jmg3 commented Mar 6, 2023

Thanks for logging this issue. A PR is welcome.

@u01jmg3 u01jmg3 assigned room34 and unassigned u01jmg3 Mar 6, 2023
@room34
Copy link
Contributor Author

room34 commented Mar 6, 2023

I have a workaround for now, but I don't know the code base well enough to offer a proper fix. My workaround (PHP >= 7) is to just append ?? '' to these lines.

@u01jmg3
Copy link
Owner

u01jmg3 commented Mar 6, 2023

?? can be rewritten as just a standard ternary (is_null($var) ? $var : '')

@u01jmg3 u01jmg3 closed this as completed in 162ac88 Apr 3, 2023
@u01jmg3 u01jmg3 added this to the v2.x.x milestone Apr 3, 2023
@room34
Copy link
Contributor Author

room34 commented Apr 3, 2023

I see that the change committed is only accounting for non-breaking spaces but not other HTML ampersand entities. Did you confirm that it was only nbsp’s that were causing the problem?

@u01jmg3
Copy link
Owner

u01jmg3 commented Apr 3, 2023

I've focussed on the non-breaking space for now as it affects the unfolding mechanism that's permitted in the iCal spec.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants