- Notifications
You must be signed in to change notification settings - Fork750
Closed
Description
Describe the bug
When usingfromISO
on an string with a timezone in square brackets, a parsing issue is revealed. Specifically, a JavaScript/TypeScript look-up object is used somewhere down the line which uses a regular Object, instead of one with a null-prototype. This means that default Object keys are considered valid, and hence, for example,constructor
is (partially) considered a valid timezone:
(pseudocode of likely implementation)
varlookup={};if(lookup["constructor"]){ ...}// true
Luckily, later logic seems to fail on these keys, so the only impact appears to be a somewhat confusing error message:
>luxon.DateTime.fromISO("2020-01-01T11:22:33+01:00[constructor]")DateTime{ts:1742121941768,_zone:SystemZone{},loc:Locale{locale:'en-US',numberingSystem:null,outputCalendar:null,intl:'en-US',weekdaysCache:{format:{},standalone:{}},monthsCache:{format:{},standalone:{}},meridiemCache:null,eraCache:{},specifiedLocale:null,fastNumbersCached:null},invalid:Invalid{reason:'unsupported zone',explanation:'the zone "function Object() { [native code] }" is not supported'},weekData:null,c:null,o:null,isLuxonDateTime:true}
To Reproduce
varluxon=require("luxon");console.log(luxon.DateTime.fromISO("2020-01-01T11:22:33+01:00[constructor]"));
Actual vs Expected behavior
The result'sinvalid.explanation
shows:
'the zone "function Object() { [native code] }" is not supported'
while we'd expect:
'the zone "constructor" is not supported'
Desktop (please complete the following information):
- OS: Linux
- Browser: Node
- Luxon version: 3.5.0
- Your timezone:
constructor
;)
Additional context
N/A
Metadata
Metadata
Assignees
Labels
No labels