Make WordPress Core

Opened 18 years ago

Closed 18 years ago

Last modified 17 years ago

#2774 closed defect (bug) (fixed)

\${1} causing problems for people

Reported by: markjaquith's profile markjaquith Owned by:
Milestone: Priority: low
Severity: normal Version: 2.0.2
Component: Administration Keywords:
Focuses: Cc:

Description

some people are having problems with the \${1} (as opposed to
1) preg_replace() reference format.

http://wordpress.org/support/topic/74496?replies=9

version: 2.0.3

Attachments (3)

2774.diff (1.7 KB) - added by mdawaffe 18 years ago.
backslash numbers too?
2774b.diff (3.8 KB) - added by mdawaffe 18 years ago.
Hit only the first number. mysql2date and date_i18n
2774c-preg.diff (4.0 KB) - added by mdawaffe 18 years ago.
preg_backslashit

Download all attachments as: .zip

Change History (14)

#1 @ryan
18 years ago

Weird. PHP bug? Reverting back will break some i18n users.

@mdawaffe
18 years ago

backslash numbers too?

#2 @mdawaffe
18 years ago

2744.diff

What if we backslashed numbers too? I think I counted the slashes correctly but am not positive.

#3 @westi
18 years ago

Looking at the more recent info in that support thread we are relying on something introduced in PHP 4.3.0 which is newer than some people are using.

http://wordpress.org/about/requirements/ says we need PHP 4.2

#4 @ryan
18 years ago

4.2 bites us in the ass again.

#5 @tenpura
18 years ago

2744.diff seems to work fine. I think you counted them right.

#6 @ryan
18 years ago

backslashit() is always used in a PCRE context, at least within WP core, so this would work fine. I wonder if plugins are using backslashit() in other contexts though. Perhaps we should introduce preg_backslashit(). Also, should slash only the digit that occurs at the head of the string? That's the only unsafe one, I believe.

#7 @ryan
18 years ago

  • Milestone set to 2.0.4

@mdawaffe
18 years ago

Hit only the first number. mysql2date and date_i18n

#8 @mdawaffe
18 years ago

I did a grep through a good chunk of wp-plugins.org and the only place backslashit was used was in a multilingual plugin that uses it in the exact same context and so would benefit from this patch. I was not able to co everything from wp-plugins; it hung on some encoding error part way through trying to co google-sitemap-generator.

2774b.diff

  1. Only replace 1st number.
  2. Fix mysql3date and date_i18n

But making a new function is fine with me too:

2744c-preg.diff

  1. All of the above in a new function preg_backslashit.

@mdawaffe
18 years ago

preg_backslashit

#9 @ryan
18 years ago

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

(In [3855]) Make replacement strings backref safe without using \${1} so as to preserve php <= 4.2 compatible. Props mdawaffe. fixes #2774

#10 @ryan
18 years ago

  • Resolution set to fixed

(In [3856]) Make replacement strings backref safe without using \${1} so as to preserve php <= 4.2 compatible. Props mdawaffe. fixes #2774

#11 @(none)
17 years ago

  • Milestone 2.0.4 deleted

Milestone 2.0.4 deleted

Note: See TracTickets for help on using tickets.