#16611 closed defect (bug) (fixed)
Too few arguments to sprintf in WP_List_Table::comments_bubble()
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Priority: | high | Milestone: | 3.1 |
| Component: | General | Version: | 3.1 |
| Severity: | normal | Keywords: | has-patch commit |
| Cc: |
Description
Not really sure where the bug is, but looks legit:
http://wordpress.org/support/topic/warning-sprintf-functionsprintf-too-few-arguments?replies=1
Attachments (5)
Change History (22)
comment:1
SergeyBiryukov — 2 years ago
SergeyBiryukov — 2 years ago
comment:2
SergeyBiryukov — 2 years ago
- Keywords has-patch added
- Keywords commit added
- Version set to 3.1
Ah, right, because sprintf() thinks those encoded chars are placeholders. Makes sense now.
- Priority changed from normal to high
$pending_phrase also needs to be escaped.
- Keywords commit removed
The URL should also be escaped.
Regardless, patch leaves an issue, due to the nature of comments_number(). If comments > 1, then comments_number() will do an str_replace() on the %. This borks the URL.
Proper function here is get_comments_number(), wrapped with number_format_i18n(). Anything else is extra we don't need or leverage, due to the arguments we pass comments_number().
- Keywords commit added
I was wondering why we were using comments_number() like this.
In 3.0, we had code that looked like the red in r15504 -- basically, massive strings going into comments_number(). We also didn't wrap the link in admin_url(), thus we had no extra percentages to screw things up. sprintf() plus admin_url(), two pretty innocuous changes, caused the regression.
The smarter structuring in r15504 in turn revealed that get_comments_number() is a better approach.
comment:10
nacin — 2 years ago
- Resolution set to fixed
- Status changed from new to closed
comment:11
nacin — 2 years ago
SergeyBiryukov — 2 years ago
comment:12
SergeyBiryukov — 2 years ago
- Resolution fixed deleted
- Status changed from closed to reopened
16611.2.diff doesn't fix the initial issue. printf() throws the same error message, as there are still encoded chars in the URL.
Added new patch.
comment:13
duck_ — 2 years ago
Do we even need the printf? Why not just string concatenation?
SergeyBiryukov — 2 years ago
comment:14
SergeyBiryukov — 2 years ago
Added patch with string concatenation.
comment:15
nacin — 2 years ago
I was going to cycle back around and just string concatenate this, but decided to leave it for 3.2. Didn't see the extra bug in my testing.
Looks good. Commit and ship.
comment:16
nacin — 2 years ago
- Resolution set to fixed
- Status changed from reopened to closed

Can reproduce with non-English characters in siteurl. The link becomes something like this: