parser(fix): more robust (UTC prefix in TzInfoParser #1165
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Pull Request Checklist
Thank you for taking the time to improve Arrow! Before submitting your pull request, please check all appropriate boxes:
tox
ormake test
to find out!).tox -e lint
ormake lint
to find out!).master
branch.If you have any questions about your code changes or any of the points above, please submit your questions along with the pull request and we will try our best to help!
Description of Changes
The changes introduced in this PR comes with unintended side effects:
It removed the end of string matching from the regex to allow for the arbitrary information at the end of the string. The intention was to match time zones like this: "(UTC+01:00) Amsterdam, Berlin, Bern, Rom, Stockholm, Wien"
This however applied to input without the "(UTC" prefix, so things like: +01:00.23 would also be handled by the code, and silently treated like "+01:00" which sounds bad. Also, misformats like this :"(UTC+01:00 Amsterdam, Berlin, Bern, Rom, Stockholm, Wien" would silently pass
The updated regex takes this into consideration, makes the closing parenthesis mandatory, and will not allow postfixes unless the string starts with the UTC prefix in parenthesis.
Notes
While this PR keeeps the original intention working, note that such timezone declarations are not valid in ISO (as far as I can tell without buying the standard :)), so it's a bit misleading.
Also, after treating the special cases here the work is basically dumped to dateutil's tz, which also seem to do some strange stuff. It'll return a tzstr for monstorities like "(UTC+01:00 Amsterdam whatver else even if it is very long as long as you dont have a comma", which probably shouln't be like that, but I really did not want to stir that much into a codebase where I don't get the intentions, so for now it behaves the same way it did before these 2 PRs , but it probably could be made better :)
We've been using this to make sure user input is valid TZ, so it's a bit of a bummer.