-
Notifications
You must be signed in to change notification settings - Fork 324
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
Sanitise name input to prevent incorrect behaviour #22
Comments
I can't seem to reproduce the bug. In any case, sanitisation of input should be implemented. If you are willing to, a PR is most welcome for its implementation. If and when I get time, I'll fix the issue. Thanks for bringing it to notice. |
Ah yes, I can reproduce it now. Seems like a trivial fix, thank you |
Hey!!
|
Go ahead! As far as I know, there are no takers yet :) |
Sweet!! |
Hey! What is the solution you are thinking about here? I don't want to try and implement something you don't think is needed |
Hey, no worries! A PR was made (#44) that addressed this issue, though it cannot be merged right now due to conflicts. You can view it and make suggestions, or if you believe you have a better, more efficient solution, create a separate PR! The solution I had in mind was a simple check to see whether the characters the person enters are alphanumeric only. |
The effect is because of the way data is read from the input. It is using common console reading. But, in my opinion, you should consider using something with a better approach: reading directly from the terminal, using ncurses for *nix systems and console.h for Windows systems. Also, I could notice that CTRL C breaks the app. It should consider using signal handling to make the app close in a controller manner instead of relying on the default signal handler which kills the application. |
@ronflima wouldn't using |
It depends on your objectives. If you want to keep the code 100% portable, you must rely on STDC++ library and that’s it. However you will have a lot of usability issues since OS interface offered by STDC++ is really high level due to its generality. |
Makes sense, though I haven't discarded the idea of using ncurses and console.h – just lacking a Windows environment to work and test on 😅. Could you elaborate on the usability issues? |
system("clear"); works only on *nix systems, for instance. On Windows, you have to use something from the old conio.h or from console.h (I'm kind of outdated on this matter), or rely on Cygwin or other POSIX layer. If the user presses CTRL-C, the game simply dies. If you press CTRL-J, which is an invalid keystroke, it will be echoed back to the terminal. You could be using a better menu based on up and down arrow keys instead to have the user to enter letters representing the menu items. But, again, it all depends on your objectives. As much you control the console, more system dependent code is needed. The way to do so is to mimic STDC library: create general interfaces, letting the implementation to be compiled according to the host operating system. |
Using |
The highscore page goes into the endless cycle and prints new lines.
upd:
Name length issue. Can be reproduced by entering name with size >18.
The text was updated successfully, but these errors were encountered: