Skip to content

Commit 702f46c

Browse files
committed
ignore invalid regex
1 parent 949b66c commit 702f46c

File tree

2 files changed

+3
-12
lines changed

2 files changed

+3
-12
lines changed

src/parser/jsonParser.ts

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -695,16 +695,7 @@ function validate(n: ASTNode | undefined, schema: JSONSchema, validationResult:
695695

696696
if (isString(schema.pattern)) {
697697
const regex = extendedRegExp(schema.pattern);
698-
if(regex === undefined) {
699-
validationResult.problems.push({
700-
location: { offset: node.offset, length: node.length },
701-
message: l10n.t('Invalid schema pattern "{0}".', schema.pattern)
702-
});
703-
704-
return;
705-
}
706-
707-
if (!(regex.test(node.value))) {
698+
if (regex && !(regex.test(node.value))) {
708699
validationResult.problems.push({
709700
location: { offset: node.offset, length: node.length },
710701
message: schema.patternErrorMessage || schema.errorMessage || l10n.t('String does not match the pattern of "{0}".', schema.pattern)

src/test/parser.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -614,12 +614,12 @@ suite('JSON Parser', () => {
614614
properties: {
615615
"one": {
616616
type: 'string',
617-
pattern: 'invalid pattern',
617+
pattern: '*+ (invalid pattern)',
618618
}
619619
}
620620
});
621621

622-
assert.strictEqual(semanticErrors!.length, 1);
622+
assert.strictEqual(semanticErrors!.length, 0);
623623

624624
semanticErrors = validate2(jsonDoc, textDoc, {
625625
type: 'object',

0 commit comments

Comments
 (0)