Wiki names should not include hyphens

Bug #54243 reported by Christian Reis
4
Affects Status Importance Assigned to Milestone
Launchpad itself
Invalid
Low
Unassigned

Bug Description

Wiki names should not contain hyphens. When they do, logging in to Moin fails with the message:

 "Invalid user name 'Foo-Bar'. Name may contain any Unicode alpha numeric character, with optional one space between words. Group page name is not allowed."

Our validator needs to check for hyphens in the field. The Wiki name generator needs to be modified to stop putting hyphens in there. I suspect that other non-alphabetical-and-numerical characters should be forbidden as well.

Christian Reis (kiko)
Changed in launchpad:
status: Unconfirmed → Confirmed
Changed in launchpad:
assignee: nobody → matsubara
importance: Untriaged → Medium
Revision history for this message
Andrew Bennetts (spiv) wrote :

Or, we could fix Moin to be less anal -- it apparently accepts random unicode letters in names, but won't accept hyphens? WTF?

Anyway, as you guess, just disallowing hyphens isn't enough. Here's the relevant Moin code:

def normalizeName(name):
    """ Make normalized user name

    Prevent impersonating another user with names containing leading,
    trailing or multiple whitespace, or using invisible unicode
    characters.

    Prevent creating user page as sub page, because '/' is not allowed
    in user names.

    Prevent using ':' and ',' which are reserved by acl.

    @param name: user name, unicode
    @rtype: unicode
    @return: user name that can be used in acl lines
    """
    # Strip non alpha numeric characters, keep white space
    name = re.sub(r"(?u)[^\w\d\s]", "", name)

    # Normalize white space. Each name can contain multiple
    # words separated with only one space.
    name = ' '.join(name.split())

    return name

def isValidName(request, name):
    """ Validate user name

    @param name: user name, unicode
    """
    normalized = normalizeName(name)
    return (name == normalized) and not wikiutil.isGroupPage(request, name)

And here's the code for wikutil.isGroupPage:

def isGroupPage(request, pagename):
    """ Is this a name of group page?

    @param pagename: the page name
    @rtype: bool
    @return: true if page is a form page
    """
    filter = re.compile(request.cfg.page_group_regex, re.UNICODE)
    return filter.search(pagename) is not None

page_group_regex by default is set to: page_group_regex = u'[a-z]Group$'

So, the rules with default Moin are:

  * only alphanumerics (including unicode alphanumerics) and whitespace
  * whitespace must be "normalised"
  * no names like "abcdefGroup"

We could try to enforce being at least this restrictive, or we could adjust Moin to have something simpler, like:

  * whitespace must be "normalised" (this actually makes sense as an anti-spoofing measure)
  * no ":", "," or "/", as explained in the normalizeName docstring.

More radical would be to:

  * have no "wiki names" in launchpad (i.e. delete the WikiName table), and just use their LP name.
  * make Moin accept any name LP gives it unconditionally (seeing as ":", ",", "/" and whitespace are already disallowed).

The transition would be painful, but the end result could be much simpler.

Revision history for this message
Christian Reis (kiko) wrote :

I think it's the least work right now to just ensure we generate and validate valid wikinames. I'm not happy with going in and trying to fix Moin, and removing WikiName is more work than just validating, I think. I say this with the perspective that at some point we might be downplaying the importance of Moin given launchpad will grow at least some wiki-like features.

Changed in launchpad:
assignee: matsubara → nobody
Revision history for this message
Curtis Hovey (sinzui) wrote :

Fixing bug 186660 would make this bug irrelevant.

Changed in launchpad-registry:
importance: Medium → Low
status: Confirmed → Triaged
Revision history for this message
Brad Crittenden (bac) wrote :

Closing due to bug 186660.

Changed in launchpad:
status: Triaged → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.