Make WordPress Core

Opened 16 years ago

Closed 16 years ago

#8419 closed enhancement (fixed)

get_sample_permalink_html not multi-byte safe

Reported by: janbrasna's profile janbrasna Owned by:
Milestone: 2.7 Priority: low
Severity: minor Version: 2.7
Component: Administration Keywords: utf multibyte has-patch
Focuses: Cc:

Description

The code of get_sample_permalink_html()

if (strlen($post_name) > 30) {
	$post_name_abridged = substr($post_name, 0, 14). '…' . substr($post_name, -14);
}

in wp-admin/includes/post.php produces invalid string in case the input is multi-byte. That doesn't happen in default, but might happen in case when 'editable_slug' filter changes the slug (e.g. #8418).

What's the consensus on mb_ functions? I've seen several cases of function check in the code as
http://trac.wordpress.org/browser/trunk/wp-includes/formatting.php?rev=9661#L513 but there are also cases like http://trac.wordpress.org/browser/trunk/wp-includes/formatting.php?rev=9661#L2071 when the presence of mb_ is not checked at all.

Attachments (1)

8419-post.php.diff (1.1 KB) - added by janbrasna 16 years ago.
Patch fixing #8419

Download all attachments as: .zip

Change History (8)

#1 @jacobsantos
16 years ago

The problem is that mb_ functions are not on all hosts, so you'll have intermittent issues on some hosts and not on others. Probably won't be fixed completely until PHP6 is out in 2020 or sometime.

#2 @jacobsantos
16 years ago

Would make sense to fix it for this problem. However, it should probably be done for all areas also.

#3 follow-up: @janbrasna
16 years ago

I'm fully aware of the mb_ issue, hence the last paragraph.

I don't have a problem with writing the patch conditionally, however if you look at the current code, there are mb_ functions already used without a check for mb_ extension.

#4 @janbrasna
16 years ago

  • Keywords dev-feedback 2nd-opinion added

I'll try to tag it for dev review to get some some insight.

#5 in reply to: ↑ 3 @westi
16 years ago

  • Keywords needs-patch added; dev-feedback 2nd-opinion removed

Replying to janbrasna:

I'm fully aware of the mb_ issue, hence the last paragraph.

I don't have a problem with writing the patch conditionally, however if you look at the current code, there are mb_ functions already used without a check for mb_ extension.

All new code must work even if the mb_ functions aren't there.

#6 @janbrasna
16 years ago

  • Keywords has-patch added; needs-patch removed

@janbrasna
16 years ago

Patch fixing #8419

#7 @ryan
16 years ago

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

(In [9986]) Use mb_* to create permalink excerpt. Props janbrasna. fixes #8419

Note: See TracTickets for help on using tickets.