Skip to content

Commit 28d2970

Browse files
committed
fix: use character class regex without lookahead for Python/Rust compatibility
1 parent b716cef commit 28d2970

7 files changed

Lines changed: 22 additions & 13 deletions

File tree

openmetadata-spec/src/main/resources/json/schema/entity/data/pipeline.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@
109109
"description": "Name that identifies this task instance uniquely.",
110110
"type": "string",
111111
"minLength": 1,
112-
"pattern": "^[^><\":|\\x00-\\x1f]*$"
112+
"pattern": "^[^><\"|\\x00-\\x1f]*$"
113113
},
114114
"displayName": {
115115
"description": "Display Name that identifies this Task. It could be title or label from the pipeline services.",

openmetadata-spec/src/main/resources/json/schema/entity/data/searchIndex.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@
9797
"type": "string",
9898
"minLength": 1,
9999
"maxLength": 256,
100-
"pattern": "^[^><\":|\\x00-\\x1f]*$"
100+
"pattern": "^[^><\"|\\x00-\\x1f]*$"
101101
},
102102
"searchIndexField": {
103103
"type": "object",

openmetadata-spec/src/main/resources/json/schema/entity/data/table.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@
209209
"type": "array",
210210
"items": {
211211
"type": "string",
212-
"pattern": "^[^><\":|\\x00-\\x1f]*$"
212+
"pattern": "^[^><\"|\\x00-\\x1f]*$"
213213
}
214214
},
215215
"referredColumns": {
@@ -236,7 +236,7 @@
236236
"description": "Local name (not fully qualified name) of the column. ColumnName is `-` when the column is not named in struct dataType. For example, BigQuery supports struct with unnamed fields.",
237237
"type": "string",
238238
"minLength": 1,
239-
"pattern": "^[^><\":|\\x00-\\x1f]*$"
239+
"pattern": "^[^><\"|\\x00-\\x1f]*$"
240240
},
241241
"partitionIntervalTypes": {
242242
"javaType": "org.openmetadata.schema.type.PartitionIntervalTypes",
@@ -275,7 +275,7 @@
275275
"columnName": {
276276
"description": "List of column names corresponding to the partition.",
277277
"type": "string",
278-
"pattern": "^[^><\":|\\x00-\\x1f]*$"
278+
"pattern": "^[^><\"|\\x00-\\x1f]*$"
279279
},
280280
"intervalType": {
281281
"$ref": "#/definitions/partitionIntervalTypes"

openmetadata-spec/src/main/resources/json/schema/type/basic.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,13 +124,13 @@
124124
"type": "string",
125125
"minLength": 1,
126126
"maxLength": 256,
127-
"pattern": "^[^><\":|\\x00-\\x1f]*$"
127+
"pattern": "^[^><\"|\\x00-\\x1f]*$"
128128
},
129129
"testCaseEntityName": {
130130
"description": "Name that identifies a test definition and test case.",
131131
"type": "string",
132132
"minLength": 1,
133-
"pattern": "^[^><\":|\\x00-\\x1f]*$"
133+
"pattern": "^[^><\"|\\x00-\\x1f]*$"
134134
},
135135
"fullyQualifiedEntityName": {
136136
"description": "A unique name that identifies an entity. Example for table 'DatabaseService.Database.Schema.Table'.",

openmetadata-spec/src/main/resources/json/schema/type/schema.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
"type": "string",
6868
"minLength": 1,
6969
"maxLength": 128,
70-
"pattern": "^[^><\":|\\x00-\\x1f]*$"
70+
"pattern": "^[^><\"|\\x00-\\x1f]*$"
7171
},
7272
"field": {
7373
"type": "object",

openmetadata-ui/src/main/resources/ui/src/constants/regex.constants.test.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,13 +160,11 @@ describe('Test Regex', () => {
160160
});
161161

162162
it('EntityName regex should fail for the invalid entity name', () => {
163-
// conatines :: in the name should fail
164-
expect(ENTITY_NAME_REGEX.test('Hello::World')).toEqual(false);
165-
// single colon also blocked as FQN separator
166-
expect(ENTITY_NAME_REGEX.test('name:bad')).toEqual(false);
163+
// contains reserved FQN characters - should fail
167164
expect(ENTITY_NAME_REGEX.test('name>bad')).toEqual(false);
168165
expect(ENTITY_NAME_REGEX.test('name<bad')).toEqual(false);
169166
expect(ENTITY_NAME_REGEX.test('name"bad')).toEqual(false);
167+
expect(ENTITY_NAME_REGEX.test('name|bad')).toEqual(false);
170168
expect(ENTITY_NAME_REGEX.test('name\nbad')).toEqual(false);
171169
expect(ENTITY_NAME_REGEX.test('name\rbad')).toEqual(false);
172170
expect(ENTITY_NAME_REGEX.test('name\x00bad')).toEqual(false);

openmetadata-ui/src/main/resources/ui/src/constants/regex.constants.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export const EMAIL_REG_EX = /^\S+@\S+\.\S+$/;
2121
* and ASCII control characters. Supports Unicode characters.
2222
*/
2323
// eslint-disable-next-line no-control-regex
24-
export const ENTITY_NAME_REGEX = /^[^><"|:\u0000-\u001f]*$/;
24+
export const ENTITY_NAME_REGEX = /^[^><"|\u0000-\u001f]*$/;
2525

2626
/**
2727
* Matches any string that does NOT contain the following:
@@ -53,16 +53,27 @@ export const TIMESTAMP_UNIX_IN_MILLISECONDS_REGEX = /^\d{13}$/;
5353

5454
export const ALL_ASTERISKS_REGEX = /^\*+$/;
5555

56+
// Split the input into pairs using `;` and handle quoted strings properly
5657
export const SEMICOLON_SPLITTER = /;(?=(?:(?:[^"]*"){2})*[^"]*$)/;
5758

59+
// Use regex to check if the string starts and ends with escape characters
5860
export const VALIDATE_ESCAPE_START_END_REGEX = /^(\\+|"+)([\s\S]*?)(\\+|"+)$/;
5961

62+
// Validates decimal numbers between 0 and 1 (inclusive)
63+
// Matches: 0, 0.5, 0.123, 1, 1.0, 1.00, etc.
6064
export const DECIMAL_ZERO_TO_ONE_REGEX = /^(0(\.\d+)?|1(\.0+)?)$/;
6165

66+
// Validates integers between 0 and 100 (inclusive)
67+
// Matches: 0, 1, 9, 10, 50, 99, 100
6268
export const INTEGER_ZERO_TO_HUNDRED_REGEX = /^(100|[1-9]?\d)$/;
6369

70+
// Validates locale/language codes (ISO 639-1 format)
71+
// Matches: en, fr, de, en-US, fr-CA, de-DE, etc.
72+
// Format: two lowercase letters optionally followed by hyphen and two uppercase letters
6473
export const LOCALE_CODE_REGEX = /^[a-z]{2}(-[A-Z]{2})?$/;
6574

75+
// Matches URLs (http/https with content, absolute paths with content, data URIs) OR filenames with image extensions
76+
// Filenames restricted to alphanumeric, hyphens, underscores, and dots for security
6677
export const IMAGE_URL_PATTERN =
6778
/^(https?:\/\/.+|\/[^\s]+|data:image\/.+)|^[\w\-.]+\.(png|jpg|jpeg|gif|svg|webp|bmp|ico)$/i;
6879

0 commit comments

Comments
 (0)