Validate port numbers better

This commit is contained in:
Ken-Håvard Lieng 2018-05-18 03:39:40 +02:00
parent 9806d6c12f
commit 2ada552220
4 changed files with 37 additions and 6 deletions

View file

@ -4,7 +4,7 @@ import { Form, withFormik } from 'formik';
import Navicon from 'containers/Navicon';
import Checkbox from 'components/ui/Checkbox';
import TextInput from 'components/ui/TextInput';
import { isValidNick, isValidChannel, isValidUsername } from 'utils';
import { isValidNick, isValidChannel, isValidUsername, isInt } from 'utils';
const getSortedDefaultChannels = createSelector(
defaults => defaults.channels,
@ -130,7 +130,7 @@ export default withFormik({
if (!values.port) {
values.port = values.ssl ? '6697' : '6667';
} else if (values.port < 1 || values.port > 65535) {
} else if (!isInt(values.port, 1, 65535)) {
errors.port = 'Invalid port';
}