Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong validation of hostname #1343

Closed
b-tab opened this issue Dec 9, 2020 · 2 comments
Closed

Wrong validation of hostname #1343

b-tab opened this issue Dec 9, 2020 · 2 comments

Comments

@b-tab
Copy link

b-tab commented Dec 9, 2020

Hello,
This change:
d9661b4 Do hostname character count in regexp.
causes that such hostname: "host: '1.2.3.'" (ending with a dot) is considered valid.
Schema:

  "host": {
          "$id": "#/snmpConfig/properties/host",
          "type": "string",
          "format": "hostname",
          "description": "The IP address of the remote alarm receiver. Hostnames are also supported in this field.",
          "title": "Remote Server IP Address",
          "default": "localhost",
          "examples": ["localhost"]
        },

The problem is with this line:

diff --git a/lib/compile/formats.js b/lib/compile/formats.js
index f51a3b7..0e6e910 100644
--- a/lib/compile/formats.js
+++ b/lib/compile/formats.js
@@ -5,7 +5,7 @@ var util = require('./util');
 var DATE = /^(\d\d\d\d)-(\d\d)-(\d\d)$/;
 var DAYS = [0,31,28,31,30,31,30,31,31,30,31,30,31];
 var TIME = /^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d(?::?\d\d)?)?$/i;
-var HOSTNAME = /^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{
0,61}[0-9a-z])?)*\.?$/i;
+var HOSTNAME = /^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0
-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i;

After reverting to old HOSTNAME variable the validation works correct.

@b-tab
Copy link
Author

b-tab commented Dec 9, 2020

ok found this: #1143

@b-tab b-tab closed this as completed Dec 9, 2020
@epoberezkin
Copy link
Member

was it fast vs full format mode? Trying to catch up :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants