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

Issue with URLs that contain an @ symbol #314

Closed
DCox44 opened this issue Feb 8, 2023 · 7 comments
Closed

Issue with URLs that contain an @ symbol #314

DCox44 opened this issue Feb 8, 2023 · 7 comments

Comments

@DCox44
Copy link

DCox44 commented Feb 8, 2023

Trying to figure out an issue, and I believe that it may be the @ symbol in a url causing the issue.

I have tried many different URLs and they all parse correctly except for the one that Outlook provides me when publishing a calendar; it contains an @ symbol. Wondering if you have come across this issue.

@s0600204
Copy link
Collaborator

s0600204 commented Feb 8, 2023

Not personally, no.

Could you provide an (anonymised) example of a URL that doesn't work, and some description of the parsing failure, please.

Along with the details requested by the Issue Template.

@DCox44
Copy link
Author

DCox44 commented Feb 9, 2023

Yeah, so I'm working on a custom plugin for my wordpress site. I essentially have a file upload and a URL text field so that I can either upload an ICS or enter in a URL..

This is the URL causing issues
https://outlook.office365.com/owa/calendar/10cc3b18eab34ab48430f469dcc10981@county-lambton.on.ca/9a08725d47e84fbf89115df19ce9634f16640673239597688242/calendar.ics

These two URLS work

https://www.calendarlabs.com/ical-calendar/ics/76/US_Holidays.ics
https://canada-holidays.ca/ics/ON?cd=true

I can download the ICS from the URL that doesn't work and upload it and it works fine.

The warnings/fatal errors I'm getting are:
Warning: file(https://...@county-lambton.on.ca/127c4cd019924e1ba54861f278c0b83518115264385855080647/calendar.ics): failed to open stream: HTTP request failed! HTTP/1.1 400 in C:\wamp64\www\Plugin Development\wp-content\plugins\icsImporter\ICal.php on line 2639

( ! ) Fatal error: Uncaught Exception: The file path or URL 'https://outlook.office365.com/owa/calendar/ceb1ae3ad22a4c66bf2b7293ebc21cfb@county-lambton.on.ca/127c4cd019924e1ba54861f278c0b83518115264385855080647/calendar.ics' does not exist. in C:\wamp64\www\Plugin Development\wp-content\plugins\icsImporter\ICal.php on line 2640

PHP Version: 7.4.26
PHP Timezone: America/Toronto
ICS Parser Version: 3.2
Windows/WAMP Server

@DCox44
Copy link
Author

DCox44 commented Feb 9, 2023

I'm initiating it like this

$ical = new ICal($file); // $file is the URL/File Location given in the form

But have also tried this

$ical = new ICal();
if (substr($file, -4) === '.ics') {
    $ical->initString($file);
} else if (substr($file, -4) === '.tmp') {
    $ical->initFile($file);
} else {
    $ical->initUrl($file);
}

I'm 80% positive I had it working by using initString, but I'm doubting myself because I can't replicate the success.

@s0600204
Copy link
Collaborator

s0600204 commented Feb 9, 2023

Looking into it this appears to be a quirk of Outlook, where it requires the User Agent string to be set in the request headers.

Try using the "httpUserAgent" argument when creating the ICal object, like so:

$ical = new ICal($url, array("httpUserAgent" => "A User Agent"));

@u01jmg3
Copy link
Owner

u01jmg3 commented Feb 9, 2023

Related previous issue: #311

@DCox44: I would always suggest looking at previous issues in case your problem has come up before.

@u01jmg3
Copy link
Owner

u01jmg3 commented Feb 10, 2023

(Note added to README: 10f0df5)

@u01jmg3
Copy link
Owner

u01jmg3 commented Feb 16, 2023

Closing as I believe the question has been answered

@u01jmg3 u01jmg3 closed this as completed Feb 16, 2023
@u01jmg3 u01jmg3 added this to the v2.x.x milestone Feb 23, 2023
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

3 participants