Java text property files: is there a way to validate?

Properties.load () seems to happily load in binary garbage if it does not find an invalid \uxxxx escape \uxxxx . Is there a way to be more strict? I just looked through the docs for the text format of the property files and I am confused how to say that the .properties file is valid.


edit: where did I come from this: I realized if I pointed my application to a 10 MB binary so that it rejected it. The 10 MB file was rejected, but only because of the \uxxxx .

I think I could create a filter on the input stream to limit some β€œnormal” amount, such as 1 MB, and filter out any key / value pairs where the key does not match an acceptable pattern. But I was hoping that it might have some kind of minimal structure to reject heavily damaged files.

+4
source share
2 answers

Property files must be in a common format. The responsibility of the application is to ensure that each individual property has a normal value.

+2
source

Check out the page . It says that the load method throws an IllegalArgumentException - if the input stream contains an invalid Unicode escape sequence.

+1
source

Source: https://habr.com/ru/post/1384203/


All Articles