WordPress.org

Make WordPress Core

Opened 4 months ago

Last modified 3 months ago

#26733 new enhancement

get_author_posts_url() is not removing accents/dicritics from the author link

Reported by: bpmvrzsf Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 3.8
Component: Formatting Keywords: close
Focuses: Cc:

Description

$author_link = get_author_posts_url( get_the_author_meta( 'ID' );
echo $author_link;

and the output will be e.g.

http://example.com/author/džiga

instead of the correct:

http://example.com/author/dziga

Could this be fixed in the next version, because only http://example.com/author/dziga will lead to the correct page. http://example.com/author/džiga will lead to 404 page.

Thanks in advance.

Attachments (1)

26733.patch (591 bytes) - added by bcworkz 4 months ago.

Download all attachments as: .zip

Change History (3)

bcworkz4 months ago

comment:1 bcworkz4 months ago

  • Cc bcworkz added
  • Component changed from General to Formatting
  • Keywords has-patch needs-testing added
  • Type changed from defect (bug) to enhancement

The author name comes from user_nicename, which by default is the same as user_login, which is not allowed to have accents/diacritics. There is not any way in the default installation to alter user_nicename. It can only be done by plugin or directly editing the DB. So not running user_nicename through remove_accents() is not a bug.

Since users could innocently alter user_nicename, it's not unreasonable to enhance get_author_posts_url() to remove any possible accents.

comment:2 nacin3 months ago

  • Keywords close added; has-patch needs-testing removed

Hi bpmvrzsf, thanks for the bug report.

You're right that it's not possible to change user_nicename. But the field is actually run through sanitize_title() (you can see this in wp_insert_user()). sanitize_title() is a general utility function that in turn runs it through remove_accents(). sanitize_title() is a slight misnomer, but really it means "sanitize this to be friendly for a URL" by removing accents, adding dashes and such.

I'm not sure how your nicename ended up with an accent, but it definitely isn't possible without a plugin or DB edit. Given that remove_accents() is run, it looks like this is actually not a bug.

Note: See TracTickets for help on using tickets.