Double-escaped strings causing improper output of special characters

stefan_pn - December 8, 2008 - 19:18
Project:Menu Breadcrumb
Version:6.x-1.1
Component:User interface
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed
Description

Every time I have a menu title with the ' (apostrophe) character in it, the character is replaced by the string &#039 ;

AttachmentSize
menuProblem.jpg47.22 KB

#1

gorbeia - December 29, 2008 - 11:11

This happens because you have set the title to be a link to the content.
In the menu_breadcrumb_init() the drupal_get_title() executes check_plain to the title which converts especial characters to html entities. Then the l function calls check_plain again converting the '&' character to the '&' entity. The l function should be passed a third argument stating that the link content is already clean html content as you can read in the l function documentation.

#2

gorbeia - December 29, 2008 - 11:19
Status:active» needs review

Patch attached

AttachmentSize
menu_breadcrumb.patch 880 bytes

#3

stefan_pn - January 19, 2009 - 19:05

Thanks for support
I cant tell if the patch is working, i'll try it on a test site.

#4

wflorian - March 4, 2009 - 14:09

I am using a theme hack to display the title of the actual node in the breadcrumbs. This does work, but I also have to face the same problem as above. Every "&" is a "&" instead. I am using the following code:

function YOURTHEME_breadcrumb($breadcrumb) {
  if (!empty($breadcrumb)) {
    $breadcrumb[] = l(drupal_get_title(), $_GET['q']);
    return '<div class="breadcrumb">'. implode(' &raquo; ', $breadcrumb) .'</div>';
  }
}

Your patch did not work for me.

-      $breadcrumb[] = l(drupal_get_title(), $_GET['q']);
+      $breadcrumb[] = l(drupal_get_title(), $_GET['q'], array('html' => TRUE,));

Is it because I am using D5? The API Code for D5 looks different. Any idea what I can do to solve this problem?

Thank you!

#5

justageek - April 6, 2009 - 15:51

Yes, if you look at api.drupal.org/api/function/l/5 you will see the parameter list is completely different, so the patch will not work for D5

I had already hacked this in and it does work for D6

#6

floown - April 20, 2009 - 07:46

The bug is still present on 6.x-1.x-dev

#7

floown - April 20, 2009 - 07:45

#8

crayon - April 22, 2009 - 16:45

function volterev_breadcrumb($breadcrumb) {
if (!empty($breadcrumb)) {
$breadcrumb = str_replace('&amp;#039;','\'',$breadcrumb);
return '<div class="breadcrumb">'. implode(' » ',$breadcrumb) .'</div>';

}
}

It works for me.

#9

lesmana - May 18, 2009 - 19:02
Title:Caracters &#039 in a Menu Breadcrumb title instead of ' (apostrophe)» Double-escaped strings causing improper output of special characters
Status:needs review» reviewed & tested by the community

The patch in #2 is the proper fix. It's a trivial enough fix to go RTBC, in my opinion.

#10

xurizaemon - August 30, 2009 - 22:16
Status:reviewed & tested by the community» fixed

fixed in http://drupal.org/cvs?commit=257684

thanks

#11

System Message - September 13, 2009 - 22:20
Status:fixed» closed

Automatically closed -- issue fixed for 2 weeks with no activity.

 
 

Drupal is a registered trademark of Dries Buytaert.