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

Filename collisions in similar names rendered identical by sanitation. #161

Open
toonarmycaptain opened this issue Apr 4, 2019 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@toonarmycaptain
Copy link
Owner

[Unproven as yet.]

Suspect that substantially similar names, such as 'Elána' and 'Eléna' will both be sanitised to 'El_na' - causing overwriting of associated avatar files.

Solve in convert_to_OOP:
Suggest fix to test for _path_safe_name in Class.students, and append hash of class or student if it is. Assignment exp would be good here:if (path-safe_name := make_path_safe_name(name)) in (student._path_safe_name for student in students)

_path_safe_name can be stored as an attribute along with name, rather than reinstantiated

Checking for name and _path_safe_name is probably necessary here, as names also need to be unique, and adding 'Elána' after 'Eléna' is still valid, even if making the _path_safe_name of 'Elána' 'El_na_93727266738', but adding a second for 'Eléna'' or.'Elána' is not.

Rechecking/recalculating the _path_safe_name, or reinstantiating the Student object when moving to another class would virtually eliminate the possibility of a hash collision on a hash appended name, more so if the class is used in producing that hash.

Calculation for this (both of the name itself and the collision check) can go on in the setter for _path_safe_name rather than in the initial if name in Class.students as identical names is all we care about disallowing the user, app will handle implementation details. This will also take care of changing _path_safe_name and avatar_path at the same time, if these are linked to the name setter. The avatar_path setter will take care of any file renames.

Avatar_path setter will need to examine an existing _avatar_path and rename the file if it is in the app_data already (otherwise copy to app_data).

@toonarmycaptain toonarmycaptain added the bug Something isn't working label Apr 4, 2019
@toonarmycaptain toonarmycaptain self-assigned this Apr 4, 2019
@toonarmycaptain
Copy link
Owner Author

This will be negated by the usage of a global id attribute for each student, easily enabled by converting the backend from pure json text files to a SQL database.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant