-
Notifications
You must be signed in to change notification settings - Fork 29
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 filter maps #208
filename filter maps #208
Conversation
67975d0
to
e75f15e
Compare
How do we go about it? |
Maybe you could use FileNameUtil. If you have windows environment you could run tests. @micheljung was complaining about test failing under windows. But it is working fine in linux env. Maybe regex can be tweaked to support both platforms' filenames |
Where should I use FileNameUtil? And which class of FileUtil, can not find any thing helping there |
Can you comment on lines ? |
e75f15e
to
c395468
Compare
The approach here is to just remove faulty characters here on upload |
@@ -71,6 +71,8 @@ void uploadMap(byte[] mapData, String mapFilename, Player author, boolean isRank | |||
Assert.notNull(author, "'author' must not be null"); | |||
Assert.isTrue(mapData.length > 0, "'mapData' must not be empty"); | |||
|
|||
mapFilename = mapFilename.replaceAll("[^\\w.\\-]", ""); //replacing all characters that are illegal in filenames |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
consider using FileNameUtil.normalizeFileName method
c395468
to
ea39852
Compare
I did |
Due to current cases on prod we not only need to check the file name but also remove all non-ascii characters from the map name itself. @axel1200 Could you add this here? |
Ehmm is that not what I was doing? |
ea39852
to
b5c59a8
Compare
@bukajsytlos I looked into the normalize file name method and it is pretty bad it replaces %| and some other character instead of replacing everything that is not a letter or an underscore. because I could imagine some additional characters that wont get replaced like this and would cause problems again... |
@axel1200 yeah I take a look at it too. The thing is that it should produce valid filenames from OS stand-point of view. If this does not meet business requirement for map names we could create new name transformation. Not sure which characters should be removed for backward compatibility |
tab for example should be removed |
for example today somebody uploaded map with : character in it and broke the vault |
Short update: I am currently working on improvements of this PR |
Do so |
f2c68c2
to
d6a55ab
Compare
d6a55ab
to
9da02aa
Compare
No description provided.