fix(typert): validate and mount remote contributions safely
This commit is contained in:
@@ -15,7 +15,7 @@ const TYPERT_REMOTE_SEGMENT_PATTERN = /^[A-Za-z0-9_$.-]+$/
|
||||
* @returns whether the value can cross the shared RPC carrier unchanged.
|
||||
*/
|
||||
export function isTypeRTRemoteSegment(value: string): boolean {
|
||||
return TYPERT_REMOTE_SEGMENT_PATTERN.test(value)
|
||||
return value !== '.' && value !== '..' && TYPERT_REMOTE_SEGMENT_PATTERN.test(value)
|
||||
}
|
||||
|
||||
export type {
|
||||
|
||||
@@ -164,6 +164,8 @@ describe('type-meta Remote declarations', () => {
|
||||
expect(() => Remote('bad/name')).toThrow('export name')
|
||||
expect(() => Remote('bad#name')).toThrow('export name')
|
||||
expect(() => Remote('bad name')).toThrow('export name')
|
||||
expect(() => Remote('.')).toThrow('export name')
|
||||
expect(() => Remote('..')).toThrow('export name')
|
||||
expect(() => RemoteContext('' as 'metaFixture')).toThrow('Context key')
|
||||
expect(() => RemoteContext('metaFixture', 'bad/name')).toThrow('export name')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user