WordPress.org

Make WordPress Core

Opened 2 years ago

Last modified 3 months ago

#20019 new enhancement

wpmu_validate_blog_signup(): Allow '.' and '-' in blog names

Reported by: fo0bar Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version: 3.0
Component: Login and Registration Keywords: dev-feedback needs-patch
Focuses: multisite Cc:

Description

Canonical uses Wordpress 3.x multisite as part of voices.canonical.com, for employees who do not have or wish to list their personal blog. The code is stock, except for one patch we maintain, which allows blog names (currently in WP as lowercase alphanumeric only) to also include '.' and '-'. This matches our global username format.

Attached is a patch extending wpmu_validate_blog_signup() to allow '.' and '-', with a tweak for the error text. We have been running the patch for awhile, and have not run across any problems with the rest of the code accepting this.

Attachments (1)

wp-ms-dotdash.patch (706 bytes) - added by fo0bar 2 years ago.
Patch to allow '.' and '-' in blog names, wpmu_validate_blog_signup()

Download all attachments as: .zip

Change History (25)

fo0bar2 years ago

Patch to allow '.' and '-' in blog names, wpmu_validate_blog_signup()

comment:1 scribu2 years ago

  • Milestone changed from Awaiting Review to 3.4

+1

comment:2 DrewAPicture2 years ago

  • Cc xoodrew@… added

comment:3 ocean902 years ago

Related: #15831

comment:4 westi2 years ago

I think dots are a good addition see #15831 but I'm not sure about "-" because we don't support it in usernames.

I think we should add support for "." and ensure we have the filters available for someone to extend the support for both usernames and hostnames to include - or other chars if they want.

comment:5 scribu2 years ago

Making the validation filterable is obviously a good idea, but is there any reason usernames can't contain '-'?

comment:6 follow-up: Ipstenu2 years ago

Westi, is it okay to have a "." in a blogname for subdomains? That could screw up a host that doesn't permit foo.bar.domain.com (which is why I always thought we didn't permit them in blognames... People can switch between subdomain and subfolder at any time, after all, if they're DB savvy).

comment:7 in reply to: ↑ 6 fo0bar2 years ago

Replying to Ipstenu:

Westi, is it okay to have a "." in a blogname for subdomains? That could screw up a host that doesn't permit foo.bar.domain.com (which is why I always thought we didn't permit them in blognames... People can switch between subdomain and subfolder at any time, after all, if they're DB savvy).

That was the only issue I could think of when upstreaming this. For our case, any default would be fine, at long as there was the ability to override it at the config level.

comment:8 follow-up: nacin2 years ago

I would like to see a filter here, but I'd rather not see the default changed.

comment:9 scribu2 years ago

Related: #20176

Last edited 2 years ago by scribu (previous) (diff)

comment:10 bluesplinter2 years ago

  • Cc steve@… added

comment:12 ryan2 years ago

  • Milestone changed from 3.4 to Future Release

We have several tickets related to this. We need to comprehensively clean this up. Punting to future release. The wpmu_validate_blog_signup filter can be used by plugins to get around this for now.

comment:13 in reply to: ↑ 8 bananastalktome2 years ago

Replying to nacin:

I would like to see a filter here, but I'd rather not see the default changed.

+1 to this suggestion. While the defaults may be somewhat restrictive, this may help the casual admin who just wants to set up WordPress and have a guarantee that it will work than the advanced one who is able and willing to do more tweaking to have things work the way they want. Loosening them can be a task left to a filter (though to be fair, there should be a similar filter added for username check as well).

comment:14 jeremyfelt8 months ago

  • Keywords dev-feedback added; has-patch removed
  • Milestone changed from Future Release to 3.7

Moving to 3.7 to discuss possible completion during this cycle.

Theoretically the wpmu_validate_blog_signup filter can be used to further validate based on the work that has already been done previously. The current patch addresses only . and -, but does not add a filter.

comment:15 follow-up: tlovett18 months ago

I don't understand why wpmu_validate_blog_signup() doesn't allow "-" in blogname by default. wp-admin/network/site-new.php runs the domain against the following regex |([a-zA-Z0-9-])+$|

Perhaps blogname is different than domain name? Can anyone clear this up for me.

Version 0, edited 8 months ago by tlovett1 (next)

comment:16 Ipstenu8 months ago

Is this a dupe of #17397 ?

(Also filter yes, please)

comment:17 tlovett18 months ago

It's not a dupe. It was explained to me by Nacin, that on the front users should only be able to create sites with a-Z0-9, whereas in the network admin, super admins should be able to use whatever characters they want.

Last edited 8 months ago by tlovett1 (previous) (diff)

comment:18 SergeyBiryukov8 months ago

#25134 was marked as a duplicate.

comment:19 SergeyBiryukov8 months ago

  • Version changed from 3.3.1 to 3.0

comment:20 lkraav8 months ago

  • Cc leho@… added
  • Version changed from 3.0 to 3.3.1

comment:21 lkraav8 months ago

  • Version changed from 3.3.1 to 3.0

comment:22 jeremyfelt7 months ago

  • Keywords needs-patch added
  • Milestone changed from 3.7 to Future Release

Punting this to a future release as we haven't figured out what a filter would look like on the regex for $blogname yet and the current filter, while clunky, will let this happen. Should be able to come around in the near future.

comment:23 jeremyfelt3 months ago

  • Component changed from Multisite to Login and Registration
  • Focuses multisite added

comment:24 in reply to: ↑ 15 drewnorthup3 months ago

Replying to tlovett1:

I don't understand why wpmu_validate_blog_signup() doesn't allow "-" in blogname by default. wp-admin/network/site-new.php runs the domain against the following regex |^([a-zA-Z0-9-])+$|

Perhaps blogname is different than domain name? Can anyone clear this up for me.

They are only 100% the same in non-network installations. (Of the normal kind anyway, advanced users can do all sorts of crazy things.) In network installations blogname can be related to either a DNS subdomain or a portion of a URI path. In the case of "folder" based network setups there's really no reason not to allow underscores.

In fact, I'd be a bit more bold than just allowing underscores (in folders / URI paths) and suggest that we should provide the option to use full UTF-8 designators (after providing for a warning to the user containing information about IDN and internationalized filesystems).(1) Note, I said the "option" to do so. In other words, make the filter a configurable option (I'd prefer doing so in wp-config.php, as that's potentially faster than putting it in the DB) with a safe default.

(1) Given that just about every "current" filesystem on every "current" OS release supports internationalized character sets the warning needn't be anything particularly dramatic.

Note: See TracTickets for help on using tickets.