Re: file upload name filtering
Lukasz Lenart <[email protected]> Sun, 9 Feb 2025 10:14:52 +0100
| Newsgroups | gmane.comp.jakarta.struts.devel |
|---|---|
| Message-ID | <CAMopvkMwwD8UGvqJCA2vcwZK6KpyLPM92Sm3tvYfq9KEV5cyuw@mail.gmail.com> |
niedz., 9 lut 2025 o 10:10 Greg Huber <[email protected]> napisał(a): > > I have now had a few uploads blocked mainly due to sentence punctuation > in the image name ie apostrophe and ampersand symbols. > > It would be better here to just escape the string and warn rather than > just block it, requiring the user to remove the characters is a waste of > time as this can easily be done in the code. > > Most apps would/should be sanitizing upload file names especially in > downloaded images. Rather than an alphanumeric replace this works well > for ascii (I have had many attempts at this🙁) > > Normalizer.normalize(fileName, > Normalizer.Form.NFD).replaceAll("([^\\p{ASCII}])", ""); Is this Struts 7 based app? I ask because I would like to focus on supporting only the main branch. Cheers Łukasz