WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#14857 closed defect (bug) (duplicate)

Shortcode causes preceding HTML tag to disappear

Reported by: cymric Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.0.1
Component: Shortcodes Keywords:
Focuses: Cc:

Description

On my Wordpress 3.0.1 installation (Atahualpa theme 3.4.4, PHP 5.2.12 + Zend 2.2.0 running on SunOS 5.10) I've succesfully added a shortcode which allows me to 'write' an image into the text of a contribution; all the hard work of figuring out where it should be displayed, how wide the container should be, and what the caption looks like is handled by the shortcode callback function. It works very well, but for one weird issue.

If I use a HTML construct like

<p>[photo location="..." link="..."]Lorem ipsum dolor sit amet...

where [photo...] expands into a complex <span>, then on random occasions the shortcode processing will swallow the preceding <p> tag. If I didn't have specific CSS applied to distinguish between the appearance of various <a> tags in <p> text (which rely on very specific child selectors, amongst which the presence of an opening <p> tag) I would never have seen the problem. If I modify the HTML to

<p><!---->[photo location="..." link="..."]Lorem ipsum dolor sit amet...

which introduces a non-visible break between the <p> tag and the shortcode, then the <p> tag is left alone. Oddly enough, the comment is not removed either.

Unfortunately there seems to be no pattern to this 'gobbling up' of preceding tags; I only know it is there, and how to work around it. On a previous occasion (dealing with ticket #14468) I had been instructed to up the PCRE backtrack limit, but setting this at an in my opinion ridiculous value of 5000000 did not cause the problem to disappear. I can provide a visual demonstration of the problem if required.

Change History (5)

comment:1 nacin4 years ago

This is a separate issue from backtracking limits. Duplicate of #10082.

comment:2 nacin4 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

comment:3 in reply to: ↑ description nacin4 years ago

Replying to cymric:

On a previous occasion (dealing with ticket #14468) I had been instructed to up the PCRE backtrack limit, but setting this at an in my opinion ridiculous value of 5000000 did not cause the problem to disappear.

Keep in mind it's just a number.

PHP 5.2 introduced a default of 100,000, but internally, PCRE's default limit is actually 10 million. (http://bugs.php.net/40846) It's really not much when you start dealing with complex expressions, a lot of content, or both.

comment:4 cymric4 years ago

I know it's just a number; I was merely trying to show initiative in trying to find a simple solution.

Anyway, apologies for not finding the #10082-ticket and opening a duplicate one by mistake: regrettably the title of #10082 isn't particularly detailed so I glanced over it :(.

comment:5 nacin4 years ago

Not a problem at all... We're approaching 15,000 tickets, it's impossible sometimes to find what you're looking for, even if you know what you're looking for :-)

Note: See TracTickets for help on using tickets.