iCal encoding for events organizer not working

Home Forums Calendar Products Events Calendar PRO iCal encoding for events organizer not working

  • This topic has 14 replies, 4 voices, and was last updated 6 years ago by Karlis.
Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • #1109404
    Karlis
    Participant

    Hello

    Organizer name is corrupted when exported to iCal. I am using Latvian characters and my name Karlis Maj Looks like this:
    ORGANIZER;CN=”K%C4%81rlis%20Maj”:MAILTO:[email protected]
    The a letter in my name Karlis is local latvian and looks like a with dash on top.
    I was browsing through forums and found good topic on the issue:
    https://theeventscalendar.com/support/forums/topic/invalid-ical-file-due-to-encoding/
    It was written that fix was included in 3.11 release: https://theeventscalendar.com/support/forums/topic/release-version-3-11-events-calendar-events-calendar-pro-add-ons/
    I have checked it and yes, it was there: “Fixed an issue with iCal email encoding (Thanks to Karen for first reporting this!)”

    So it seems that it came up again or it was not completely fixed. Can you please take a look on that?

    PS: I do not own Events Calendar Pro, but i have purchased Events Tickets plus and i would expect the whole family of Events Calendar should function well regardless of what plugin i have purchased.

    #1109733
    Andras
    Keymaster

    Hello Karlis,

    I’m sorry you are experiencing this issue. I will try to help you with this.

    Could you please share with me your system information? Here is a link explaining how to do that.

    And meanwhile can you also send me a link to an event where this is happening?

    Thanks,
    Andras

    #1109739
    Karlis
    Participant

    This reply is private.

    #1110216
    Andras
    Keymaster

    Hello Karlis,

    Thanks for sharing that information. Yes, it might help us if you share all system information. To share your site’s details, highlight the entirety of that black box on the Help page and copy it into the System Information box on the forum post.

    Meanwhile I did some digging and it seems like another encoding issue. I will need to talk with my colleagues if there is a quick fix for this.

    I will get back to you shortly. Thanks for your patience in advance!

    Andras

    #1110231
    Andras
    Keymaster

    Hello again,

    Good news: we might have a solution! 🙂 Let’s try this.

    Please copy the following code into your functions.php file. (Appearance > Editor > choose functions.php on the right side.)

    Note: for any customizations, using a child theme is highly recommended, otherwise all modifications will be lost with a theme update. You can read more about child themes here.

    function pos_ical_encoding_fix( $parts ) {
    foreach ( $parts as &$single_part ) {
    // We're only interested in modifying the organizer field
    if ( 0 !== strpos( $single_part, 'ORGANIZER' ) ) continue;
    
    // Extract the common name
    $cn_begins = strpos( $single_part, 'CN="' ) + 4;
    $cn_ends   = strpos( $single_part, '"', $cn_begins );
    $cn_len    = $cn_ends - $cn_begins;
    
    // Decode it
    $encoded_cn = substr( $single_part, $cn_begins, $cn_len );
    $decoded_cn = rawurldecode( $encoded_cn );
    
    // Re-encode problem characters (ampersands, semicolons and dbl quotes)
    $safe_cn = str_replace( '&', '%26', $decoded_cn );
    $safe_cn = str_replace( ';', '%3B', $safe_cn );
    $safe_cn = str_replace( '"', '%22', $safe_cn );
    
    // Write back our changes
    $single_part = substr_replace( $single_part, $safe_cn, $cn_begins, $cn_len );
    }
    
    return $parts;
    }
    add_filter( 'tribe_ical_feed_item', 'pos_ical_encoding_fix' );
    
    
    Let me know if this solves the iCal export problem.
    
    Cheers,
    Andras
    #1110250
    Karlis
    Participant

    Something is wrong with the code. It break my site.

    #1110389
    Andras
    Keymaster

    Hi Karlis,

    I’m sorry about that. That might have been my mistake. Let me put the code here again properly.


    function pos_ical_encoding_fix( $parts ) {
    foreach ( $parts as &$single_part ) {
    // We're only interested in modifying the organizer field
    if ( 0 !== strpos( $single_part, 'ORGANIZER' ) ) continue;

            // Extract the common name
    $cn_begins = strpos( $single_part, 'CN="' ) + 4;
    $cn_ends = strpos( $single_part, '"', $cn_begins );
    $cn_len = $cn_ends - $cn_begins;

            // Decode it
    $encoded_cn = substr( $single_part, $cn_begins, $cn_len );
    $decoded_cn = rawurldecode( $encoded_cn );

    // Re-encode problem characters (ampersands, semicolons and dbl quotes)
    $safe_cn = str_replace( '&', '%26', $decoded_cn );
    $safe_cn = str_replace( ';', '%3B', $safe_cn );
    $safe_cn = str_replace( '"', '%22', $safe_cn );

            // Write back our changes
    $single_part = substr_replace( $single_part, $safe_cn, $cn_begins, $cn_len );
    }
    return $parts;
    }
    add_filter( 'tribe_ical_feed_item', 'pos_ical_encoding_fix' );

    Please, try with this one. Make sure that the code goes in your functions.php file after the <?php tag.

    Again, I’m sorry and please let me know if this works. Me and a colleague tested this code and solved the problem.

    Cheers,
    Andras

    #1110848
    Karlis
    Participant

    Yup. This worked fine.

    Will you add this to plugin as next fix, or should i leave this code forever in functions.php?

    Additionally, not related to this topic, currently all iCal events are imported to separate calendar with my site name and not imported to default Outlook calendar.
    Here are few topics about it:
    https://theeventscalendar.com/support/forums/topic/ical-single-event-import-file-creates-new-calendar/
    https://theeventscalendar.com/support/forums/topic/ical-not-importing-correctly-into-outlook-how-do-i-access-the-ics-generating-c/

    I am using now outlook calendar fix plugin from Andy Fragen, however it’ bit pitty, that i have to use separate plugin for such a small issue. Will you develop a fix for that?

    #1111129
    Andras
    Keymaster

    Hello Karlis,

    For now, leave it in functions.php for sure.

    We’ve been discussing with dev that this should go in as a bugfix, so highly likely it will be included. However, I cannot commit to any timing.

    currently all iCal events are imported to separate calendar with my site name and not imported to default Outlook calendar

    I will need some time to discuss this with the team. Interesting enough, on my local environment I have the same problem with the exported events, but when exporting an event from your site, it works fine and asks me to save it.

    Can you maybe point me to the specific entry which produces this for you?

    Cheers,
    Andras

     

    #1111136
    Karlis
    Participant

    This can be achieved with plugin.

    The Events Calendar Outlook Import Fix

    Actually what it does is just remove one line in iCal and that’s it. It should be 30 sec work for your devs.

    #1111142
    Andras
    Keymaster

    Thanks for the link Karlis, I will share it with the devs.

    It surely wouldn’t take long to remove that line, however I’m also sure it is there for a purpose. 🙂 I will let them check.

    If there’s nothing more at the moment I can help you with, then I will put this thread on ‘pending fix’ so whenever there is an update you will get notified.

    If you have any other questions, then feel free to open another thread, we’ll be here to help you.

    Cheers,
    Andras

    #1117093
    Support Droid
    Keymaster

    This topic has not been active for quite some time and will now be closed.

    If you still need assistance please simply open a new topic (linking to this one if necessary)
    and one of the team will be only too happy to help.

    #1455176
    Nico
    Member

    Hi there,

    Just wanted to share with you that a new maintenance release is out, including a new filter to fix this issue.

    To prevent the X-WR-CALNAME to show up in the export, you’ll need to paste the following code in you theme (or child theme) functions.php file or into a customization plugin if you use one:

    add_filter( 'tribe_ical_feed_calname', '__return_null' );

    Find out more about this release → https://theeventscalendar.com/maintenance-release-for-the-week-of-12-feburary-2018/

    Update the plugins and let us know if the fix works for your site,
    Cheers,
    Nico

    #1475515
    Support Droid
    Keymaster

    Hey there! This thread has been pretty quiet for the last three weeks, so we’re going to go ahead and close it to avoid confusion with other topics. If you’re still looking for help with this, please do open a new thread, reference this one and we’d be more than happy to continue the conversation over there.

    Thanks so much!
    The Events Calendar Support Team

Viewing 14 posts - 1 through 14 (of 14 total)
  • The topic ‘iCal encoding for events organizer not working’ is closed to new replies.