WordPress.org

Make WordPress Core

Opened 5 years ago

Closed 5 years ago

#9083 closed defect (bug) (invalid)

Bug in do_shortcode_tag (or in input to it)

Reported by: shaisachs Owned by:
Milestone: Priority: normal
Severity: normal Version: 2.7
Component: General Keywords: shortcode
Focuses: Cc:

Description

While working with the wp-downloadmanager plugin, I discovered that a shortcode of the form:
[download id="3"]

Doesn't display anything when the post appears in full-page form. But it does display correctly in teaser form.

So I dug around a bit, and tracked the problem down to do_shortcode_tag. In particular, the different results can be tracked to this line:

        $attr = shortcode_parse_atts($m[2]);

In the teaser form, $m[2] is '[download id="3"]'. In the full-page form, it's '[download id="3"]'. That messes up the call to shortcode_parse_atts.

What I've done for the time being is replaced the above with:

        $m[2] = str_replace(' ', ' ', $m[2]);
        $attr = shortcode_parse_atts($m[2]);

That "works", but I suspect there's a deeper problem which I'm perhaps not solving. Am I on the right track here, or is something else going wrong?

Change History (7)

comment:1 filosofo5 years ago

I am 95% certain that a plugin is adding that  , not core WordPress. Does this still occur when all plugins are deactivated?

comment:2 shaisachs5 years ago

Yep. I just disabled all plugins except for WP Download manager, and I'm still getting an "nbsp" fed into shortcode_parse_atts. When I deactivate WP Download manager, do_shortcode_tag isn't called, of course, so I see the unfiltered '[download id="3"]' in the page. When I view source on that, there's an nbsp between download and id with no white space characters, i.e. '[download id="3"]'.

comment:3 filosofo5 years ago

There must be something else adding the nbsp; there's nothing in WordPress that would do this. What theme are you using? Do you see the nbsp when you edit the post in HTML mode?

comment:4 Viper007Bond5 years ago

I have multiple plugins that use similar shortcodes and they work just fine. I believe filosofo is correct in that it's not WordPress at fault here.

comment:5 shaisachs5 years ago

  • Resolution set to fixed
  • Status changed from new to closed

Aha, you are right! Very sorry for mistakenly posting the bug here. The nbsp was being inserted by some code in the Hybrid theme (hybrid/library/functions -> text-filters.php). I'll report the bug to them; in the meantime, do_shortcode_tag is cleared of any wrongdoing.

Thanks for all the help!

comment:6 Viper007Bond5 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

comment:7 Viper007Bond5 years ago

  • Milestone 2.7.2 deleted
  • Resolution set to invalid
  • Status changed from reopened to closed
Note: See TracTickets for help on using tickets.