Skip to content

Commit

Permalink
Fix: prevent term and out labels from allowing a.b.c
Browse files Browse the repository at this point in the history
  • Loading branch information
01Parzival10 committed Oct 11, 2024
1 parent 4cca5f6 commit 03127ce
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/features/dfdElements/outputPortBehaviorValidation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ export class PortBehaviorValidator {

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

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

Expand Down Expand Up @@ -335,6 +336,15 @@ export class PortBehaviorValidator {
idx = line.indexOf(inputLabelValue, idx + 1);
}
}

console.log(inputMatch);

if (inputMatch[3] !== undefined) {
inputAccessErrors.push({
line: lineNumber,
message: `invalid label definition`,
});
}
}

const node = port.parent;
Expand Down Expand Up @@ -451,6 +461,13 @@ export class PortBehaviorValidator {
}
}
}

if (typeValuePair.split(".")[2] !== undefined) {
inputAccessErrors.push({
line: lineNumber,
message: `invalid label definition`,
});
}
}

return inputAccessErrors.length > 0 ? inputAccessErrors : [];
Expand Down

0 comments on commit 03127ce

Please sign in to comment.