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 ' ;
| Attachment | Size |
|---|---|
| menuProblem.jpg | 47.22 KB |

#1
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
Patch attached
#3
Thanks for support
I cant tell if the patch is working, i'll try it on a test site.
#4
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(' » ', $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
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
The bug is still present on 6.x-1.x-dev
#7
#8
function volterev_breadcrumb($breadcrumb) {
if (!empty($breadcrumb)) {
$breadcrumb = str_replace('&#039;','\'',$breadcrumb);
return '<div class="breadcrumb">'. implode(' » ',$breadcrumb) .'</div>';
}
}
It works for me.
#9
The patch in #2 is the proper fix. It's a trivial enough fix to go RTBC, in my opinion.
#10
fixed in http://drupal.org/cvs?commit=257684
thanks
#11
Automatically closed -- issue fixed for 2 weeks with no activity.