3
votes

Using google calendar v3

Calendar has events with ampersands in the summary e.g. mother&father Problem is that this is not found when using the Events:list q parameter from code.

When using the API from this google API test page, the behaviour is as follows:

  • Searching for mother&father results no events
  • Searching for "mother&father" (with quotes) returns the expected events

When doing the same thing from code -with or without quotes- doesn't return the events.

The code works fine when searching for events without ampersands in the summary.

So question is: how can the q parameter be used from code, to retrieve events with ampersands in the name?

EDIT 17 Dec 2019: Provide more details

SET UP : google calendar with id , with an event on 19 dec 2019 with title "mother&father child1"

CASE1: Looking for "mother&father", result ("items": look at the end of the response) is empty:

_api_list_args['q'] = 'mother&father'
GoogleConfig.service.events().list(**_api_list_args).execute()
GET https://www.googleapis.com/calendar/v3/calendars/<my_cal_id>%40group.calendar.google.com/events?singleEvents=true&q=father&orderBy=startTime&maxResults=8&timeMin=2019-12-17T14%3A47%3A17.205463Z&timeMax=2020-06-16T00%3A00%3A00.000Z&alt=json
{'kind': 'calendar#events',
 'etag': '"p334fb5lauquec0g"',
 'summary': 'SWD local',
 'updated': '2019-12-17T14:46:39.117Z',
 'timeZone': 'Europe/Brussels',
 'accessRole': 'writer',
 'defaultReminders': [],
 'items': []}

CASE2: Looking for "father", result is also empty:

_api_list_args['q'] = 'father'
GoogleConfig.service.events().list(**_api_list_args).execute()
URL being requested: GET https://www.googleapis.com/calendar/v3/calendars/<my_cal_id>%40group.calendar.google.com/events?singleEvents=true&q=father&orderBy=startTime&maxResults=8&timeMin=2019-12-17T14%3A47%3A17.205463Z&timeMax=2020-06-16T00%3A00%3A00.000Z&alt=json
{'kind': 'calendar#events',
 'etag': '"p328ajglquuuec0g"',
 'summary': 'SWD local',
 'updated': '2019-12-17T14:51:41.818Z',
 'timeZone': 'Europe/Brussels',
 'accessRole': 'writer',
 'defaultReminders': [],
 'items': []}

CASE3: Looking for "child1", now it finds the event:

_api_list_args['q'] = 'child1'
GoogleConfig.service.events().list(**_api_list_args).execute()
URL being requested: GET https://www.googleapis.com/calendar/v3/calendars/<my_cal_id>%40group.calendar.google.com/events?singleEvents=true&q=child1&orderBy=startTime&maxResults=8&timeMin=2019-12-17T14%3A47%3A17.205463Z&timeMax=2020-06-16T00%3A00%3A00.000Z&alt=json
{'kind': 'calendar#events',
 'etag': '"p338fbacsvauec0g"',
 'summary': 'SWD local',
 'updated': '2019-12-17T15:04:03.810Z',
 'timeZone': 'Europe/Brussels',
 'accessRole': 'writer',
 'defaultReminders': [],
 'items': [{'kind': 'calendar#event',
         'etag': '"3153190087620000"',
         'id': 'p939brcc2r83cu9q52sjagcua4_20191219T200000Z',
         'status': 'confirmed',
         'htmlLink': 'https://www.google.com/calendar/event?eid=cDkzOWJyY2MycjgzY3U5cTUyc2phZ2N1YTRfMjAxOTEyMTlUMjAwMDAwWiBnNXJ1cTl1Z2xlNWc2ZTFhMms1cmZyM2hjY0Bn',
         'created': '2019-11-29T16:58:45.000Z',
         'updated': '2019-12-17T15:04:03.810Z',
         'summary': 'mother&father child1',
         'description': 'my nice description<br><a href="<mysite>" id="ow2358" __is_owner="true"><mysite></a>',
         'location': '#MYLOCATION',
         'creator': {'email': '<myemail>'},
         'organizer': {'email': '<my_cal_id>@group.calendar.google.com',
         'displayName': 'SWD local',
         'self': True},
         'start': {'dateTime': '2019-12-19T21:00:00+01:00', 'timeZone': 'Europe/Brussels'},
         'end': {'dateTime': '2019-12-19T22:00:00+01:00', 'timeZone': 'Europe/Brussels'},
         'recurringEventId': 'p939brcc2r83cu9q52sjagcua4',
         'originalStartTime': {'dateTime': '2019-12-19T21:00:00+01:00', 'timeZone': 'Europe/Brussels'},
         'iCalUID': '[email protected]',
         'sequence': 0,
         'extendedProperties': {'shared': {'course_162': '1'}},
         'reminders': {'useDefault': True}}]}

BUT: This one also fails: look for "chil" ie part of a word... CASE 4: Look for "chil"

_api_list_args['q'] = 'chil'
GoogleConfig.service.events().list(**_api_list_args).execute()
URL being requested: GET https://www.googleapis.com/calendar/v3/calendars/<my_cal_id>%40group.calendar.google.com/events?singleEvents=true&q=chil&orderBy=startTime&maxResults=8&timeMin=2019-12-17T14%3A47%3A17.205463Z&timeMax=2020-06-16T00%3A00%3A00.000Z&alt=json
{'kind': 'calendar#events',
'etag': '"p338fbacsvauec0g"',
'summary': 'SWD local',
'updated': '2019-12-17T15:04:03.810Z',
'timeZone': 'Europe/Brussels',
'accessRole': 'writer',
'defaultReminders': [],
'items': []}

Does google 'q' parameter only searches for whole words??

1
Could you provide the code you have and what the final request object looks like? - ZektorH
I have updated the question with code, the request and some more details - Davy

1 Answers

0
votes

My guess is that google removes the "&" due to a security reason. Most of xss attacks are prevented when removing special charecters of url like "&". Try replacing the "&" with "&amp" or with "%26"