I have discovered an odd situation related to advanced forum. To be honest, I'm not entirely sure whether this is truly a bug, but I'd like to report it and see if others can reproduce the behavior.

In short, when displaying a forum (e.g. domain.com/forum/1) and a forum topic contains a non-breaking space ( ) in the teaser, the following error is generated:

htmlspecialchars(): Invalid multibyte sequence in argument in /var/www/fox3drupal-6.22/includes/bootstrap.inc on line 856.

This is called within the check_plain() function. I used devel to display a backtrace, which is shown in the attached image (I'll attempt to include it inline here):

backtrace image

I've tried to use the backtrace to figure out why the teaser of a topic is even being read or passed down the chain to check_plain(), but I cannot figure it out. At a minimum, can someone tell me why the teaser is even being used this way?

Unfortunately the problem is not 100% reproduceable. For me, I can reproduce the problem 100% of the time on my production server (just my luck!) but my dev box doesn't show the problem. In theory, they are both configured the same (Ubuntu 10.04, php 5.3.2), and I checked the mbstring settings with phpinfo() but I don't see any major difference.

I would appreciate anyone else willing to recreate my situation, simply creating a forum topic with   in the first part of the node such that it will be contained in the teaser, and then display that forum list. Even if the problem isn't reproduceable for you, would you please look at my backtrace image and tell me how/why my teaser text is being passed to check_plain()?

I have my workaround (removing the non-breaking space), but I fear my server is just waiting for another user to type something which causes it to happen again.

Thanks in advance.

CommentFileSizeAuthor
htmlspecialchars_error.jpg39.45 KBcarteriii
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

carteriii’s picture

I just realized one more piece of information may be relevant. I'm using a theme created from Zen (though I have not customized anything with respect to forum layout or styling), and advanced forum is using its "Silver Bells" theme.

mcdruid’s picture

Status: Active » Postponed (maintainer needs more info)

Looking at the last few steps of your backtrace, you can follow the function calls:

render_as_link -> l -> drupal_attributes -> check_plain

So I'd put some simple debug code into one of those functions temporarily, and try to spot the parameter which is causing the issue, working further backwards into the views handler if necessary.

It looks like check_plain is choking on the value of an html attribute which is being set on a link?

I am not convinced this is an AF problem, but will be interested to see what you can find out.

carteriii’s picture

By running the backtrace, I did get a full list of parameters to each function. I could see that the teaser of a forum topic was the parameter being passed down through the chain (render_as_link, etc.). That's part of what confused me, and I (at least with the time spent last night) couldn't figure out what was trying to turn my teaser into a link.

I can now see that the teaser is used as a tooltip when I hover my mouse above the topic title. So now my question becomes, what code is responsible for using the teaser as a tooltip? Does the text for the tooltip (the teaser) need to be passed through render_as_link and the subsequent calls? The tooltip itself isn't an actual link, so perhaps the view is doing that even if advanced forum isn't using it?

Having said that, I still don't understand why htmlspecialchars throws the error when   is included in the text. The underlying problem may be a server/php configuration issue which is simply showing itself in this case.

Michelle’s picture

It's been a while but I believe the "tooltip" is done in the Views template file and it's just like a title attribute on the link or something like that. The data for the "tooltip" is coming from a Views field so it's possible it's doing some sort of processing on it. Sorry this is vague... I haven't looked at that bit of code in a very, very long time.

Michelle

mcdruid’s picture

Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)

Ok, looks like it's the fact that on all of these views, the node Title field is set to be output as a link, and to use the [teaser] as "Alt text:"

> grep -rin '\[teaser\]' .
./includes/views/advanced_forum_unanswered_topics.view:53:      'alt' => '[teaser]',
./includes/views/advanced_forum_group_topic_list.view:101:      'alt' => '[teaser]',
./includes/views/advanced_forum_user_posts.view:136:      'alt' => '[teaser]',
./includes/views/advanced_forum_topic_list.view:105:      'alt' => '[teaser]',
./includes/views/advanced_forum_active_topics.view:109:      'alt' => '[teaser]',
./includes/views/advanced_forum_new_topics.view:80:      'alt' => '[teaser]',

The description of the "Alt text" field in views UI is this: "Text to place as "alt" text which most browsers display as a tooltip when hovering over the link." and it looks like the views handlers are doing some magic to set the teaser as the title attribute on the link.

So hopefully that clears up the mystery.

I can confirm that if I put a   in the teaser of one of my topics, I get a title attribute with the   intact, and no errors. So I think you're correct that it looks like a problem that's peculiar to your environment, and not an AF (or views) bug.

Have you tried commenting out the check for PHP > 5.2.5 in check_plain?

Anyway, sorry - I don't think this is a bug that belongs in the AF queue - could be moved to core if you can confirm it's a reproducible problem in check_plain.

carteriii’s picture

Ah, that helps tremendously, and thank you. I agree this isn't an advanced forum bug . . . I did say in my initial post that I wasn't sure :=) Anyway, thanks. I really do appreciate your help. I saw advanced_forum at the top of my backtrace stack and I saw the error at the bottom, but I obviously got lost in finding the true cause somewhere in between.

rfay’s picture

I have this problem with an Advanced Forum view as well. Same version.