Make WordPress Core

Opened 12 years ago

Closed 12 years ago

Last modified 8 years ago

#22260 closed defect (bug) (fixed)

Incorrect sprintf replacement specifiers

Reported by: westi's profile westi Owned by: westi's profile westi
Milestone: 3.5 Priority: normal
Severity: normal Version: 3.4.2
Component: I18N Keywords:
Focuses: Cc:

Description

We have a number of places in core where we are incorrectly using %1s instead of %1$s while this doesn't break the functionality of the code it does have the potential to lead to incorrect translations if the i18n teams re-order the replacements buy don't know to insert the missing $.

This is because without the $ we are specifying the minimum with of the replacement rather than a numbered replacement.

From http://uk.php.net/sprintf:

An optional number, a width specifier that says how many characters (minimum) this conversion should result in.

We need to review the following and fix them as appropriate:

  • wp-admin/includes/ms.php:409
  • wp-admin/network/site-new.php:88
  • wp-admin/users.php:232
  • wp-admin/users.php:234
  • wp-admin/users.php:333
  • wp-admin/users.php:335
  • wp-admin/users.php:337
  • wp-includes/ms-functions.php:1018
  • wp-includes/ms-functions.php:1053

Attachments (1)

22260.2.diff (17.0 KB) - added by DrewAPicture 12 years ago.

Download all attachments as: .zip

Change History (11)

#1 @westi
12 years ago

  • Owner set to westi
  • Status changed from new to accepted

#2 @westi
12 years ago

In [22270]:

i18n: Fix the usage of sprintf replacements in the Multisite include files. See #22260.

#3 @westi
12 years ago

In [22271]:

i18n: Fix the usage of sprintf replacements in the Multisite admin include files. See #22260.

#4 @westi
12 years ago

In [22272]:

i18n: Fix the usage of sprintf replacements in the Multisite Network Admin new site page. See #22260.

#5 @westi
12 years ago

In [22273]:

i18n: Fix the usage of sprintf replacements in the user management admin page. See #22260.

#6 @westi
12 years ago

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

That fixes all the cases I could find.

#7 follow-up: @DrewAPicture
12 years ago

If you want it, 22260.2.diff adds number specifiers to many sprintf's using several consecutive standalone specifiers like %s, %o, %d, etc.

#8 in reply to: ↑ 7 @westi
12 years ago

Replying to DrewAPicture:

If you want it, 22260.2.diff adds number specifiers to many sprintf's using several consecutive standalone specifiers like %s, %o, %d, etc.

I would love for us to do a sweep through everything and do this, but it should be on a new ticket and not for this release :)

Could you open a new ticket for this please.

#9 @nacin
12 years ago

In 22664:

Add manual new lines to a string, as double quotes with \n is not optimal due to sprintf-parsing reasons. props SergeyBiryukov, fixes #22486. see #22260.

This ticket was mentioned in Slack in #core-i18n by sergey. View the logs.


8 years ago

Note: See TracTickets for help on using tickets.