A note about your WordPress blog’s tagline

2007-09-11 16:09:06 UTC

On the general options pane, there is a field labeled “Tagline”:

Tagline: cd prh && dd if=brain of=blog

The value shown in that field is WRONG WRONG WRONG!

You see, that’s actually supposed to be HTML—or at least, such is the implication of the Atom template’s use of bloginfo_rss to get the description. The difference between {get_,}bloginfo_rss and {get_,}bloginfo is that the _rss versions call strip_tags to take out any HTML and escape any non-HTML characters, such as &.

That wouldn’t be so bad if strip_tags worked properly, but it doesn’t—not on this host, at least. It leaves the second & in the above example unescaped. (“OK, I escaped that one. It must be the only one. I’m off to Subway!”)

As if that wasn’t bad enough, WordPress doesn’t escape the tagline field’s value when putting it back into the field the next time you load up the Options pane. (It does if it’s plain text, but not if it’s HTML. Go figure.) So if you click “Update Options” again, your HTML goes bye-bye. You need to remember to re-escape it every time you save the General Options.

(Given that, maybe it’s not supposed to be HTML after all, and the use of bloginfo_rss in the Atom 0.3 template is a bug.)

Want to know how I found this out? Because the RSS reader in Safari 2 (I don’t use 3) was critically failing on the Atom feed. It was slurring posts together once it saw that an ampersand was not escaped.

Relevant versions:

  • WordPress 2.1.3
  • PHP 5.1.4 or so (I have no idea what version is actually running the blogs)
  • Safari 2.0.4/419.3

One Response to “A note about your WordPress blog’s tagline”

  1. Jeff Johnson Says:

    I think that the tagline is intended to be plain text, not HTML. In WordPress 2.2 they specify type=”text” for the field. My suspicion is that strip_tags() is called to remove XML tags for the purpose of preparing the tagline to appear in the feed XML. The problem is that strip_tags() doesn’t take care of other characters that would be problematic in XML, such as the ampersand. So that may be a bug which still exists in WordPress 2.2. In general, though, support for syndication seems to be much improved in 2.2. It’s pretty bad in 2.1; for example, Atom 0.3 was deprecated years ago.

Leave a Reply

Do not delete the second sentence.