[EventCalendar] ec3_get_calendar() not translating ampersands into character entities

Alex Tingle alex at firetree.net
Fri Oct 12 10:41:53 UTC 2007


Hi Elizabeth,

ejm wrote:
> This is how a post_title with an ampersand appears in both WP and in
> SQL results:

[snip]

Those are all fine and as I would expect. Unicode characters are stored 
in UTF-8 in your database, and displayed correctly by WordPress.


> I am enclosing a zip file with eventcalendar3/day.php and
> template-functions.php  for the two wordpresses I run:

Ah ha! I've found your problem. The day.php file you sent me has this 
comment:

   // ejm change array(',','@'),
   ...
   // ejm change $safe_title.=' @'.$time;

That's very well disciplined of you to note where you've made changes. 
Unfortunately, that change has caused your troubles...

Your version looks like this...

// ejm change array(',','@'),
     $safe_title=strip_tags($title);
     $safe_title=
       str_replace(
         array(',',';'), <<===================== PROBLEM
         ' ',
         htmlspecialchars(
           stripslashes($safe_title),
           ENT_QUOTES,
           get_settings('blog_charset')
         )
       );
// ejm change $safe_title.=' @'.$time;
     if($is_event)
     {
       $safe_title.='. '.$time;
       $this->is_event=True;
     }

That replaces every ';' with ' ' - which is exactly what you are seeing.

Obviously, you don't want the '@' symbol before the times. So, try this...

     $safe_title=strip_tags($title);
     $safe_title=
       str_replace(
         ',', // AT changed from: array(',','@'),
         ' ',
         htmlspecialchars(
           stripslashes($safe_title),
           ENT_QUOTES,
           get_option('blog_charset')
         )
       );
     if($is_event)
     {
       $safe_title.=' '.$time; // AT changed from: ' @'
       $this->is_event=True;
     }


 > Thank you very much for all your attention to this. It really is very
 > kind of you.

Thank you for persisting with it. Obviously this is simply a problem 
that you've introduced yourself, but the one you started with was a 
genuine bug. That's fixed now, thanks to you.

-Alex

-- 
:: Let me solve your problems: http://www.firetree.net/consulting/
:: alex.tingle AT firetree.net  +44-7901-552763



More information about the EventCalendar mailing list