Skip to content

Commit 3af93e6

Browse files
committed
jCard property names and parameter names must be lowercase (thx Jan Willem Stegink)
1 parent 2dff822 commit 3af93e6

File tree

1 file changed

+26
-5
lines changed

1 file changed

+26
-5
lines changed

lib/rdap-validator.js

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ self.testURL = function(url, type, serverType, context) {
6666
};
6767

6868
/**
69-
* Invoked when the fetch has completed.
69+
* Invoked when the fetch has completed. This tests an HTTP response (ie headers
70+
* and body)
7071
* @param {Response} response
7172
*/
7273
self.testResponse = function(response) {
@@ -118,6 +119,10 @@ self.testResponse = function(response) {
118119
);
119120
};
120121

122+
/**
123+
* This is called by testResponse() and validates the JSON body of the response.
124+
* @param json
125+
*/
121126
self.validateResponse = function(json) {
122127

123128
self.path = ["$"];
@@ -689,6 +694,12 @@ self.validateJCardPropertyType = function(property) {
689694
"section-3.3",
690695
)) return;
691696

697+
self.add(
698+
property[0] === property[0].toLowerCase(),
699+
`Property name '${property[0]}' MUST be in lowercase.`,
700+
"section-3.3",
701+
);
702+
692703
if ("rir" == self.lastTestedServerType) {
693704
self.pushSpec("nro");
694705

@@ -713,11 +724,17 @@ self.validateJCardPropertyType = function(property) {
713724
* Validate a JCard property parameter object.
714725
*/
715726
self.validateJCardPropertyParameters = function(property) {
716-
self.add(
727+
if (self.add(
717728
self.isObject(property[1]),
718729
"Item #2 of a jCard property MUST be an object.",
719730
"section-3.3",
720-
);
731+
)) {
732+
self.add(
733+
Object.keys(property[1]).length == Object.keys(property[1]).filter(n => n === n.toLowerCase()).length,
734+
"jCard parameter names MUST be lowercase.",
735+
"section-3.4"
736+
)
737+
}
721738
};
722739

723740
/**
@@ -2492,7 +2509,9 @@ self.isULabel = function(label) {
24922509

24932510
/**
24942511
* This stores the JSONPath query that identifies the value in the response that
2495-
* is currently being validated.
2512+
* is currently being validated. When add() is called, the a JSON Path
2513+
* expression is generated using this stack, so the specific component of the
2514+
* JSON response can be associated with the message.
24962515
*/
24972516
self.path = [];
24982517

@@ -2518,7 +2537,9 @@ self.popPath = function(last) {
25182537

25192538
/**
25202539
* This keeps track of the specification document that the response is being
2521-
* validated against.
2540+
* validated against. when add() is called, the topmost entry in the stack is
2541+
* copied into the message, so the message can be associated with a particular
2542+
* specification (RFC, etc).
25222543
*/
25232544
self.specStack = [];
25242545

0 commit comments

Comments
 (0)