Comment 1 for bug 54243

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.