fix(typert): validate and mount remote contributions safely

This commit is contained in:
imccyu
2026-08-07 14:07:19 +08:00
parent 737c12935a
commit 2fe4a53557
9 changed files with 173 additions and 25 deletions

View File

@@ -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 {

View File

@@ -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')