Skip to content

Commit 03127ce

Browse files
committed
Fix: prevent term and out labels from allowing a.b.c
1 parent 4cca5f6 commit 03127ce

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

src/features/dfdElements/outputPortBehaviorValidation.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ export class PortBehaviorValidator {
3232

3333
// Regex that validates a term
3434
// Has the label type and label value that should be set as capturing groups.
35-
private static readonly TERM_REGEX = /^(\s*|!|TRUE|FALSE|\|\||&&|\(|\)|([A-Za-z0-9_]+\.[A-Za-z0-9_]+))+$/;
35+
private static readonly TERM_REGEX =
36+
/^(\s*|!|TRUE|FALSE|\|\||&&|\(|\)|([A-Za-z0-9_]+\.[A-Za-z0-9_]+(?![A-Za-z0-9_]*\.[A-Za-z0-9_]*)))+$/g;
3637

3738
private static readonly LABEL_REGEX = /([A-Za-z0-9_]+)\.([A-Za-z0-9_]+)/g;
3839

@@ -335,6 +336,15 @@ export class PortBehaviorValidator {
335336
idx = line.indexOf(inputLabelValue, idx + 1);
336337
}
337338
}
339+
340+
console.log(inputMatch);
341+
342+
if (inputMatch[3] !== undefined) {
343+
inputAccessErrors.push({
344+
line: lineNumber,
345+
message: `invalid label definition`,
346+
});
347+
}
338348
}
339349

340350
const node = port.parent;
@@ -451,6 +461,13 @@ export class PortBehaviorValidator {
451461
}
452462
}
453463
}
464+
465+
if (typeValuePair.split(".")[2] !== undefined) {
466+
inputAccessErrors.push({
467+
line: lineNumber,
468+
message: `invalid label definition`,
469+
});
470+
}
454471
}
455472

456473
return inputAccessErrors.length > 0 ? inputAccessErrors : [];

0 commit comments

Comments
 (0)