Make WordPress Core

Opened 11 years ago

Closed 10 years ago

#11097 closed defect (bug) (wontfix)

shortcode_parse_atts - bug in preg_replace in PHP 4.3.2

Reported by: bonaireguy Owned by:
Milestone: Priority: high
Severity: major Version: 2.8.6
Component: Shortcodes Keywords: needs-patch gsoc
Focuses: Cc:


On line 230 of wp-include/shortcodes.php is the line:

$text = preg_replace("/[\x{00a0}\x{200b}]+/u", " ", $text);

With $text = ' id="attachment_7" align="aligncenter" width="156" caption="Fresh Mint Tea in The Netherlands' the above preg_replace incorrectly returns an empty string in PHP 4.3.2

In PHP 5.1.6 it returns the proper result (namely the same as the input $text string shown above).

While a PHP bug is not really a WordPress bug, the minimum requirements for WordPress (see http://codex.wordpress.org/Hosting_WordPress) indicate that PHP 4.3 is compatible.

Two solutions:

1) Use a different method to replace the UTF-8 space codes the above preg_replace() call is meant to replace with ASCII spaces.

2) Change the minimum requirements for WordPress (seems overkill).

Note that this problem means that folks with PHP 4.3.2 and WordPress will not have proper shortcode processing, including captions for photos (which is I how discovered this).

Attachments (1)

test_preg_replace.php (255 bytes) - added by bonaireguy 11 years ago.
Test code to demonstrate the documented bug

Download all attachments as: .zip

Change History (7)

11 years ago

Test code to demonstrate the documented bug

#1 @bonaireguy
11 years ago

Correction - it's in line 227 of wp-includes/shortcodes.php in WordPress 2.8.5

#2 @bonaireguy
11 years ago

  • Severity changed from normal to major
  • Version changed from 2.8.5 to 2.9.1

This problem still exists in WordPress 2.9.1 as of this morning.

#3 @bonaireguy
11 years ago

  • Version changed from 2.9.1 to 2.9.2

This problem still exists in WordPress 2.9.2. It is now on line 228 of wp-includes/shortcodes.php

#4 @dd32
11 years ago

  • Keywords needs-patch added; shortcodes php preg_replace removed
  • Milestone changed from Unassigned to Future Release
  • Version changed from 2.9.2 to 2.8.6

Please leave the version field left to the initial version which the bug is known to exist in.

#5 @wojtek.szkutnik
11 years ago

  • Keywords gsoc added

#6 @dd32
10 years ago

  • Milestone Future Release deleted
  • Resolution set to wontfix
  • Status changed from new to closed

Closing as wontfix, Missed the boat for 3.1 which will be the last PHP4 compatible release.

Note: See TracTickets for help on using tickets.