When a new calendar is added, validation updates the URL if the HTTP response is a redirect. The issue is that it does so without looking at the HTTP status code:
https://gitlab.com/bitfireAT/icsx5/blob/master/app/src/main/java/at/bitfire/icsdroid/ui/AddCalendarValidationFragment.kt#L116
The URL should only be updated for 301 and 308 (and not for 302 and 307).
This is done better for actually fetching the calendar later. Here, 308 (== StatusLine.HTTP_PERM_REDIRECT
) is handled. I think 301 should be added here:
https://gitlab.com/bitfireAT/icsx5/blob/master/app/src/main/java/at/bitfire/icsdroid/ProcessEventsTask.kt#L81
Maybe it’s easiest to handle all of this only when fetching and not when validating, not sure.
The concrete issue I have is with a “link share” on Seafile installation. When accessing the original URL1, Seafile redirects you to URL2 and generates an access token that is valid for accessing URL2 for only one hour. So when ICSx5 replaces the URL during validation, everything just works for one hour. After one hour, Seafile returns 400 because the access token has expired. (Yes, it should probably return 403 but that’s a different issue.)