fix(fs): guard langFromPath against Object.prototype extension keys
A filename whose extension is an Object.prototype key (foo.constructor, foo.__proto__) resolved to the inherited member through the plain-object index, so a function reached the read card's lang hint and failed the tool-output JSON validation, failing an otherwise successful read. Look the extension up as an own property only. Added rejection tests, converted the zh Note headings to the all-English sibling convention, and named the parallel-file-reads terminal golden as the TUI-unchanged evidence in the Testing section (both languages).
This commit is contained in:
@@ -139,6 +139,15 @@ describe('langFromPath', () => {
|
||||
expect(langFromPath('data.unknownext')).toBeUndefined()
|
||||
expect(langFromPath('trailingdot.')).toBeUndefined()
|
||||
})
|
||||
|
||||
it('returns undefined for a filename whose extension is an Object.prototype key', () => {
|
||||
// Own-property lookup only: these must not resolve to the inherited member
|
||||
// (a function/object), which would fail the tool-output JSON validation.
|
||||
expect(langFromPath('foo.constructor')).toBeUndefined()
|
||||
expect(langFromPath('foo.__proto__')).toBeUndefined()
|
||||
expect(langFromPath('foo.toString')).toBeUndefined()
|
||||
expect(langFromPath('foo.hasOwnProperty')).toBeUndefined()
|
||||
})
|
||||
})
|
||||
|
||||
describe('readMetaFromMeta', () => {
|
||||
|
||||
Reference in New Issue
Block a user