Archives

All posts for the month April, 2019

In the latest version of PrimeFaces they apparently made the regex validation for “allowTypes” more restrictive.

Previously we had allowTypes="/(\.|\/)(gif|jpe?g|png)$/"

This will allow .gif/.jpg/.jpeg/.png files but not allow .GIF/.JPG/.JPEG/.PNG files.

To remove the case sensitivity you just add the i flag, for insensitivity:

allowTypes="/(\.|\/)(gif|jpe?g|png)$/i"

What is particularly bad about PF 7.0 is that it will allow it to run the uploader as it will pass the first step of the client-side validation, but when it sends to the server it will fail the validation and not alert the user that it failed (!!!), thus making a silent error that will cause users a lot of grief.