diff --git a/docs/en_US/release_notes_6_5.rst b/docs/en_US/release_notes_6_5.rst index 35d611088..0dcfa9733 100644 --- a/docs/en_US/release_notes_6_5.rst +++ b/docs/en_US/release_notes_6_5.rst @@ -22,4 +22,5 @@ Bug fixes | `Issue #7035 `_ - Fixed an issue where connections keep open to (closed) connections on the initial connection to the database server. | `Issue #7085 `_ - Ensure that Partitioned tables should be visible correctly when creating multiple partition levels. | `Issue #7100 `_ - Fixed an issue where the Browser tree gets disappears when scrolling sequences. -| `Issue #7135 `_ - Enforce the minimum Windows version that the installer will run on. +| `Issue #7127 `_ - Added validation for Hostname in the server dialog. +| `Issue #7135 `_ - Enforce the minimum Windows version that the installer will run on. diff --git a/web/pgadmin/browser/server_groups/servers/static/js/server.ui.js b/web/pgadmin/browser/server_groups/servers/static/js/server.ui.js index b0dd28e86..c197bd3e9 100644 --- a/web/pgadmin/browser/server_groups/servers/static/js/server.ui.js +++ b/web/pgadmin/browser/server_groups/servers/static/js/server.ui.js @@ -11,6 +11,7 @@ import gettext from 'sources/gettext'; import _ from 'lodash'; import {Address4, Address6} from 'ip-address'; + import BaseUISchema from 'sources/SchemaView/base_schema.ui'; import pgAdmin from 'sources/pgadmin'; import {default as supportedServers} from 'pgadmin.server.supported_servers'; @@ -84,6 +85,10 @@ export default class ServerSchema extends BaseUISchema { return pgAdmin.Browser.utils.pg_libpq_version < 100000; } + validateHost(str) { + return /^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$|^(([a-zA-Z]|[a-zA-Z][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z]|[A-Za-z][A-Za-z0-9\-]*[A-Za-z0-9])$|^\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*$/.test(str); + } + get baseFields() { let obj = this; return [ @@ -470,6 +475,17 @@ export default class ServerSchema extends BaseUISchema { setError('hostaddr', null); } + /* Hostname, IP address validate */ + if (state.host) { + if (!this.validateHost(state.host)){ + errmsg = gettext('Host name must be valid hostname or IPv4 or IPv6 address.'); + setError('host', errmsg); + return true; + } else { + setError('host', null); + } + } + if(isEmptyString(state.username)) { errmsg = gettext('Username must be specified.'); setError('username', errmsg);