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

Errno 22 in case player has special characters in their name #9557

Closed
dreamscached opened this issue Sep 21, 2022 · 4 comments
Closed

Errno 22 in case player has special characters in their name #9557

dreamscached opened this issue Sep 21, 2022 · 4 comments
Labels
Projects

Comments

@dreamscached
Copy link
Member

dreamscached commented Sep 21, 2022

In case player has special characters in their name (in my case, one of Discord users who shared an error had :D in their name, could it be done in circumvention of name choosing system or was it possible in earlier releases?), this line will raise EINVAL on Windows machines when MAS will attempt to create a 'For <name>.txt' file.

persistent._mas_bday_hint_filename = "For " + player + ".txt"

Traceback follows:

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "game/script-ch30.rpy", line 1541, in script call
  File "game/event-handler.rpy", line 3119, in script call
  File "game/script-holidays.rpy", line 7266, in script
  File "game/script-holidays.rpy", line 7300, in <module>
  File "game/script-affection.rpy", line 2707, in _write_txt
IOError: [Errno 22] invalid mode ('w') or filename: u'D:/! DDLC-1.1.1-pc/characters/For XXX :D.txt'

-- Full Traceback ------------------------------------------------------------

Full traceback:
  File "game/script-ch30.rpy", line 1541, in script call
  File "game/event-handler.rpy", line 3119, in script call
  File "game/script-holidays.rpy", line 7266, in script
  File "D:\! DDLC-1.1.1-pc\renpy\ast.py", line 814, in execute
    renpy.python.py_exec_bytecode(self.code.bytecode, self.hide, store=self.store)
  File "D:\! DDLC-1.1.1-pc\renpy\python.py", line 1719, in py_exec_bytecode
    exec bytecode in globals, locals
  File "game/script-holidays.rpy", line 7300, in <module>
  File "game/script-affection.rpy", line 2707, in _write_txt
IOError: [Errno 22] invalid mode ('w') or filename: u'D:/! DDLC-1.1.1-pc/characters/For XXX :D.txt'

Windows-8-6.2.9200
Ren'Py 6.99.12.4.2187
Monika After Story 0.12.9
@Booplicate
Copy link
Member

Did they use a translation? You can't use : in the name.

@dreamscached
Copy link
Member Author

Nope, they told me they don't.

@Booplicate
Copy link
Member

We could add a try/except there, but I'm actually not sure because that would mean next time such case occurs, the use wouldn't know why they didn't get the note, and perhaps would just miss the event entirely.

We should probably sanitise the name before using it in file system.
Actually, I just found out, we allow any characters for the name, no idea how we missed it.

@Booplicate Booplicate added the bug label Sep 22, 2022
@Booplicate Booplicate added this to High priority in Bugs Sep 22, 2022
@dreamscached
Copy link
Member Author

I think we could rather replace problematic characters, or strip them altogether. I can do a PR for that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Bugs
  
High priority
Development

No branches or pull requests

2 participants