mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Added validation for Hostname in the server dialog. Fixes #7127
This commit is contained in:
parent
41bcce09ce
commit
3e86ed5d21
@ -22,4 +22,5 @@ Bug fixes
|
||||
| `Issue #7035 <https://redmine.postgresql.org/issues/7035>`_ - Fixed an issue where connections keep open to (closed) connections on the initial connection to the database server.
|
||||
| `Issue #7085 <https://redmine.postgresql.org/issues/7085>`_ - Ensure that Partitioned tables should be visible correctly when creating multiple partition levels.
|
||||
| `Issue #7100 <https://redmine.postgresql.org/issues/7100>`_ - Fixed an issue where the Browser tree gets disappears when scrolling sequences.
|
||||
| `Issue #7135 <https://redmine.postgresql.org/issues/7100>`_ - Enforce the minimum Windows version that the installer will run on.
|
||||
| `Issue #7127 <https://redmine.postgresql.org/issues/7127>`_ - Added validation for Hostname in the server dialog.
|
||||
| `Issue #7135 <https://redmine.postgresql.org/issues/7135>`_ - Enforce the minimum Windows version that the installer will run on.
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user