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

Sanitize existing names/descriptions and prevent new issues #160

Merged
merged 1 commit into from
Nov 30, 2023

Conversation

jt-traub
Copy link
Contributor

Since this is a diff against the old (pre-unit test) code, I cannot prove that this works, but I will be applying an analogous patch +
unit tests against main here shortly. This feels correct in that
it will

a) strip out the 'real' unit/faction/object number from the name. b) rebuild the name with the new set of legal characters (and reattach the unit/faction/object number)
c) sanitize the descriptions to only the new set of legal characters on readin.
d) prevent (via the change to islegal()) any new names or descriptions from containing the bogus characters.

The non-allowed characters are now the set ()[]; instead of just () as before.

Since this is a diff against the old (pre-unit test) code, I cannot
prove that this works, but I will be applying an analogous patch +
unit tests against main here shortly.   This feels correct in that
it will

a) strip out the 'real' unit/faction/object number from the name.
b) rebuild the name with the new set of legal characters (and reattach
the unit/faction/object number)
c) sanitize the descriptions to only the new set of legal characters on
readin.
d) prevent (via the change to islegal()) any new names or descriptions
from containing the bogus characters.

The non-allowed characters are now the set ()[]; instead of just
() as before.
@@ -289,10 +289,10 @@ int AString::getat()
char islegal(char c)
{
if ((c>='a' && c<='z') || (c>='A' && c<='Z') || (c>='0' && c<='9') ||
c=='!' || c=='[' || c==']' || c==',' || c=='.' || c==' ' ||
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it will not allow [ and ] in the unit names

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nor in object or faction names.

@valdisz valdisz merged commit 2ad1047 into Atlantis-PBEM:master Nov 30, 2023
5 checks passed
@jt-traub jt-traub deleted the jt-fix-name-shenanigans branch November 30, 2023 19:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants