Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Giving a formal name with a character such as ', /, \, causes briefcase new to crash #1810

Closed
mfreydavis opened this issue May 20, 2024 · 2 comments · Fixed by #1827
Closed
Labels
bug A crash or error in behavior.

Comments

@mfreydavis
Copy link

Describe the bug

When you execute briefcase new and set the name to / you get an IndexError: string index out of range.

This is also true for some other characters such as /, \ , ", ', and ,
It appears to effect all of that class of characters due to the way the class name is created.

The problem appears to be in config.py make_class_name:

# Normalize to NFKC form, then remove any character that isn't
# in the allowed categories, or is the underscore character;
# Capitalize the resulting word.
class_name = "".join(
    ch
    for ch in unicodedata.normalize("NFKC", formal_name)
    if unicodedata.category(ch) in xid_continue or ch in {"_"}
)

This causes the name to be stripped of all characters, making the string length zero.

This causes an attempt to make a class name to fail

# If the first character isn't in the 'start' character set,
# and it isn't already an underscore, prepend an underscore.
if unicodedata.category(class_name[0]) not in xid_start and class_name[0] != "_":
    class_name = f"_{class_name}"

return class_name

Steps to reproduce

  1. Run briefcase new
  2. When prompted Formal Name [Hello World]: enter \

Expected behavior

Validation should force you to create a legal name, or additionally prompt you to create proper class names.

Screenshots

No response

Environment

  • Operating System: Linux
  • Python version: 3.11
  • Software versions:
    • Briefcase: 0.3.19.dev26+g96734be6.d20240520
    • Toga:
    • ...

Logs

No response

Additional context

No response

@mfreydavis mfreydavis added the bug A crash or error in behavior. label May 20, 2024
@mblahay
Copy link
Contributor

mblahay commented May 21, 2024

I'm looking into this

@mblahay
Copy link
Contributor

mblahay commented May 21, 2024

I have a fix developed. Essentially added a validator function to the input. Working on the pull request process now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A crash or error in behavior.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants