Skip to content

Unify project name rules with server #4516

@harminius

Description

@harminius

The server rules for the project name are stricter, which means the project created in the app cannot be uploaded to the cloud.

This user's project cannot be uploaded due to an apostrophe.
Image

Hint for the fix:
The relevant server check is done here:
https://github.com/MerginMaps/server/blob/master/server/mergin/sync/forms.py#L17
Most of the checks are sorted, but the regex probably slipped through.

def is_reserved_word(name: str) -> str | None:
    """Check if name is reserved in system"""
    reserved = r"^support$|^helpdesk$|^merginmaps$|^lutraconsulting$|^mergin$|^lutra$|^input$|^admin$|^sales$"
    if re.match(reserved, name) is not None:
        return "The provided value is invalid."
    return None


def has_valid_characters(name: str) -> str | None:
    """Check if name contains only valid characters"""
    if re.match(r"^[\w\s\-\.]+$", name) is None:
        return "Please use only alphanumeric or the following -_. characters."
    return None


def has_valid_first_character(name: str) -> str | None:
    """Check if name contains only valid characters in first position"""
    if re.match(r"^[\s.].*$", name) is not None:
        return f"Value can not start with space or dot."
    return None

from pathvalidate import (
    validate_filename,
)
def check_filename(name: str) -> str | None:
    """Check if name contains only valid characters for filename"""
    error = None
    try:
        validate_filename(name)
    except ValidationError:
        error = "The provided value is invalid."
    return error

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugsyncIntegration with Mergin Maps backend
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions