anselal / antminer-monitor

Cryptocurrency ASIC mining hardware monitor using a simple web interface
GNU General Public License v3.0
228 stars 145 forks source link

Validate input for IP address #130

Closed anselal closed 6 years ago

anselal commented 6 years ago

We should validate the input on all forms to avoid db injections. HTML has the option to define a pattern attribute for input tags like:

<input required="" type="text" name="ip" pattern="^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$">
anselal commented 6 years ago

Also we should add a title attribute to customise the tooltip message on error:

<input required="" type="text" name="ip" pattern="^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$" title="Please add a valid IP address">