Ticket #2774 (closed defect (bug): fixed)

Opened 3 years ago

Last modified 2 years ago

\${1} causing problems for people

Reported by: markjaquith Assigned to: anonymous
Priority: low Milestone:
Component: Administration Version: 2.0.2
Severity: normal Keywords:
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

2774.diff (1.7 kB) - added by mdawaffe on 06/02/06 18:45:25.
backslash numbers too?
2774b.diff (3.8 kB) - added by mdawaffe on 06/05/06 19:10:39.
Hit only the first number. mysql2date and date_i18n
2774c-preg.diff (4.0 kB) - added by mdawaffe on 06/05/06 19:20:13.
preg_backslashit

Change History

06/02/06 18:01:23 changed by ryan

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

06/02/06 18:45:25 changed by mdawaffe

  • attachment 2774.diff added.

backslash numbers too?

06/02/06 18:49:18 changed by mdawaffe

2744.diff

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

06/02/06 22:11:41 changed by westi

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

06/02/06 22:17:23 changed by ryan

4.2 bites us in the ass again.

06/04/06 05:46:29 changed by tenpura

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

06/04/06 18:21:30 changed by ryan

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.

06/04/06 21:10:32 changed by ryan

  • milestone set to 2.0.4.

06/05/06 19:10:39 changed by mdawaffe

  • attachment 2774b.diff added.

Hit only the first number. mysql2date and date_i18n

06/05/06 19:19:57 changed by mdawaffe

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.

06/05/06 19:20:13 changed by mdawaffe

  • attachment 2774c-preg.diff added.

preg_backslashit

06/08/06 03:17:05 changed by ryan

  • status changed from new to closed.
  • resolution set to fixed.

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

06/08/06 03:21:07 changed by ryan

  • status changed from closed to closed.
  • 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/30/06 19:41:50 changed by

  • milestone deleted.

Milestone 2.0.4 deleted