Closed (fixed)
Project:
Event
Version:
4.7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
4 May 2006 at 12:44 UTC
Updated:
27 Mar 2007 at 19:17 UTC
Jump to comment: Most recent file
Comments
Comment #1
Tiburón commentedHi,
I downloaded (with wget) the iCalendar feed from groups.drupal.org and got this (just a snippet of one of the events):
Checking RFC2445 (Internet Calendaring and Scheduling Core Object Specification, iCalendar, http://www.ietf.org/rfc/rfc2445.txt), especially the following section on escaping human readable content, it seems to me that geodan is on the right track.
The following snippet is the definition of the element #text used to represent text/data associateted with iCalendar properties like SUMMARY, DESCRIPTION and so on. The snippet is taken from the Wikipedia version of RFC2445 as it is more webfriendly. Source: http://en.wikipedia.org/wiki/RFC2445_Syntax_Reference#Text
It looks like none of these escapes are used by the events module when generating #text fields for the iCalendar feed.
I have not checked if there are other deviations from the iCalendar specification.
This issue is a dublicate of the Google Calendar issue at http://drupal.org/node/58554, but the subject of this issue is more to the point.
Regards,
Christian Larsen
Comment #2
geodaniel commentedThe attached patch adds in an escaping function for text elements and escapes the summary and description fields.
Comment #3
killes@www.drop.org commentedI don't understand too much about iCal so I just applied the patch. :p
Comment #4
geodaniel commentedThanks killes - did you check to make sure it didn't break the export code though? I don't have a test instance running that I could run it on at the moment, but the code seemed to work ok independently.
Comment #5
(not verified) commentedComment #6
solipsist commentedIs this committed only to CVS or is it also available in the current stable (4.7.0) version of the Event module?
We need this feature to work. It also seems our calendar feed doesn't work in iCalendar either.
Comment #7
ahs_boy commentedNot sure where else to post this: I run a PHP-based calendar server that also accepts and parses iCalendar feeds. One of my clients is using Drupal, and attempted to attach their feed to my server, which promptly munged much of the HTML in many of the fields. So I did some digging, and discovered the "DQUOTE" referred to in this bug report.
It appears that Drupal is actually using the text string "DQUOTE" in its code, to represent the double-quote character. This is a complete misunderstanding of RFC 2445! The string "DQUOTE" used in RFC 2445 is actually a definition, not a substitution string!
Section 4.1 of the RFC describes "contentlines", and uses a series of definitions to describe the format that text needs to follow. In places where they refer to DQUOTE, it is used like this:
The Common Name parameter follows this format: "CN" "=" param-value.
In the definition that explains how "param-value" is formatted, we see:
param-value = paramtext OR quoted-string
quoted-string = DQUOTE *QSAFE-CHAR DQUOTE
DQUOTE = %x22
So they really mean that a Common Name should look like: CN="John Smith"
A DQUOTE character, followed by one or more QSAFE characters, followed by a DQUOTE character.
The Drupal code for escaping characters says:
* For double quote use: DQUOTE
which is totally incorrect. Double-quotes are escaped as \" in the same manner as single-quotes.
On a related note, RFC 2445 recommends that contentlines "should" be folded, so that they are no more than 75 octets in length, and the Drupal feeds don't appear to do that. Not required, but it's also nice to stick closely to the spec whenever possible.
I have simple fold() and unfold() functions in PHP, which I'd be happy to contribute.
Any chance the DQUOTE issue could be resolved, at least? I'm not a Drupal user or contributor, so I'm not familiar with your development process, but if I could be of help, let me know.
Comment #8
geodaniel commentedSorry, looks like that's my fault then for the misunderstanding the comments in #1 when rolling the patch. Thanks for bringing this back up.
If I get a chance I'll come back to this and update the patch, but if anyone else is happy to fix it, please do. ahs_boy, if you're willing, could you update the patch for
function ical_escape_text($text)in #2 and post a replacement?Comment #9
geodaniel commentedI've just been doing some more testing on this. When I create a test site and add a few simple events, it works alright and I can subscribe to it with Sunbird and Google Calendar. When I try to subscribe to groups.drupal.org iCal feed then Google Calendar tells me that it can't parse it, but Sunbird can - anything beyond the first line of a text field is ignored though.
It looks like there have been some UTF8 compatibility bits added in to the iCal feeds since this patch was put through, and I am seeing strings such as " February 7th. Time will be =" and "
text here
=0D=0A" being included in feeds.
Comment #10
geodaniel commentedAlso see this issue thread: http://drupal.org/node/84740
Comment #11
geodaniel commentedmarking this as dup in favour of the other one
Comment #12
ahs_boy commentedHere's a replacement for the patch file posted earlier. I didn't have access to the original source, so I simply modified the existing patch file. Line counts stay the same. The new patch simply replaces one str_replace() call with another.
Related to other aspects of this discussion, I do NOT use quoted-printable encoding for my calendar feeds (http://www.radicalendar.org), and it handles UTF-8 just fine. There are occasional Hebrew, Spanish, and Japanese feeds on the site, so it gets a good workout.
The question of whether or not to strip HTML tags from the feeds is another matter: if the feed is displayed on another web calendar, the HTML comes through nicely. If the feed is destined for Apple's iCal, the HTML tags are rendered as plain text, which ends up looking ugly. The only good solution may be to offer HTML and plain text versions of the feeds.
Comment #13
ahs_boy commentedAnd here's a patch for anyone who had already used the earlier patch. A patch patch.
Comment #14
geodaniel commentedComment #15
geodaniel commentedComment #16
killes@www.drop.org commentedI am a bot confused: Which is the orrect patch? #12? or #12 and #13?
Did anybody try any of these patches?
Comment #17
geodaniel commentedI think it's the one in #13, but I'm not sure that's a total fix (haven't tried it yet). It will still leave the quotes around colons, which I don't think is correct.
Comment #18
karens commentedI have been trying to get two-way ical feeds working and in the process I think I have the ical.inc file working correctly (or at least working so I can export feeds into Google and import them into my own applications).
The patch must have some line ending issues because it looks messier than it is. The changes are:
1) $calname needed to be escaped because it had commas in it (April 1, 2007 to April 2, 2007)
2) Quoted printable was, in fact, not necessary, so I removed it and used the ical escape instead
3) It was not necessary to do strip_tags() so I commented it out (I left it in as a reminder in case there are any more problems later).
4) The ical escaping needed the above-mentioned fix to escape the quote marks rather than use QUOTE
5) The colon needed regular escaping, not the funny stuff with the quotes around it
6) The _ical_tz($tz) function was completely screwed up (which wasn't apparent until I tried to import a feed). It is doing a db_query on a non-existant table. I fixed it to use the timezones.inc file instead.
I tested an event with non-ascii characters and single and double quotes in both the title and the description and was able to get the feed to show up in Google Calendar. I was able to use the import part of the file to import feeds into the Calendar module (a demo is at http://www.elderweb.com/demo/calendar), so I have feeds working in both directions. Sorry, I don't have code to do the import into the event module calendar, but now that it is working someone should be able to do that (or I may try to do it when I have more time).
Comment #19
karens commentedThe previous patch had some date module stuff still in it. Here's the one for the event module.
Comment #20
killes@www.drop.org commentedThanks! applied
Comment #21
steve hanson commentedJust thought I'd report that since this patch export to Google works just great for me - thanks Karen!
Comment #22
HorsePunchKid commentedIt's possible this is just iCal4j not behaving properly, but my http://severinghaus.org/projects/icv/">iCalendar validator is complaining about the blank lines that are now showing up. I seem to recall having trouble with the same phenomenon in Sunbird, but that was a year or two ago, and I may be wrong.
I don't see anything in RFC 2445 §4.1 ("Content Lines") saying it's specifically illegal to have blank lines, but the examples don't appear to have any.
In any case, I went ahead and
trim()ed the return inical_escape_text()(@@ 80), and it seems fine now. Any thoughts?Comment #23
(not verified) commented