Use actual ISO8601 timestamps for masto API #425

Merged
floatingghost merged 2 commits from darkkirb/akkoma:fix-invalid-datetime into develop 2023-01-09 22:12:29 +00:00
Contributor

Some users post posts with spoofed timestamp, and some clients will have issues with certain dates. Tusky for example crashes if the date is any sooner than 1 BCE (“year zero” in the representation).

I limited the range of what is considered a valid date to be somewhere between the years 1583 and 9999 (inclusive).

The numbers have been chosen because:

  • ISO 8601 only allows years before 1583 with “mutual agreement”
  • Years after 9999 could cause issues with certain clients as well
Some users post posts with spoofed timestamp, and some clients will have issues with certain dates. Tusky for example crashes if the date is any sooner than 1 BCE (“year zero” in the representation). I limited the range of what is considered a valid date to be somewhere between the years 1583 and 9999 (inclusive). The numbers have been chosen because: - ISO 8601 only allows years before 1583 with “mutual agreement” - Years after 9999 could cause issues with certain clients as well

this should probably be in the core object validation rather than an mrf

this should probably be in the core object validation rather than an mrf
Author
Contributor

Okay so the more I read about this I am realizing that this is the intersection of a bunch of slightly different definitions of timestamps:

  • ISO 8601 which is the definition used by the Mastodon API
  • RFC 3339 which is what Tusky is using, and allows years from 1BCE (0000, erroneously called year 0), and 9999CE
  • Elixir’s version of ISO8601, a superset of ISO8601, which allows for years between 10000BCE and 9999CE
  • ActivityStream 2’s date format, which allows for more than 4 digit years, BCE dates, etc, but does not allow for “year 0” (1BCE is -0001 and not 0000)

I think it would be more correct to put it in the Masto API code because currently akkoma is violating mastodon’s API constraints by passing invalid ISO8601 dates

Okay so the more I read about this I am realizing that this is the intersection of a bunch of slightly different definitions of timestamps: - ISO 8601 which is the definition used by the Mastodon API - RFC 3339 which is what Tusky is using, and allows years from 1BCE (0000, erroneously called year 0), and 9999CE - Elixir’s version of ISO8601, a superset of ISO8601, which allows for years between 10000BCE and 9999CE - ActivityStream 2’s date format, which allows for more than 4 digit years, BCE dates, etc, but does not allow for “year 0” (1BCE is -0001 and not 0000) I think it would be more correct to put it in the Masto API code because currently akkoma is violating mastodon’s API constraints by passing invalid ISO8601 dates
darkkirb force-pushed fix-invalid-datetime from 18bcb5fd75 to 2ce4f96f6e 2023-01-07 21:00:25 +00:00 Compare
darkkirb changed title from Add MRF policy for fixing invalid publish dates to Use actual ISO8601 timestamps for masto API 2023-01-07 21:00:54 +00:00
Author
Contributor

Okay I moved the fix to the the commonapi code. This doesn’t fix the minor bug where year 0 is accepted internally and negative years are off by one year

Okay I moved the fix to the the commonapi code. This doesn’t fix the minor bug where year 0 is accepted internally and negative years are off by one year
Author
Contributor

Okay just swinging by and saying that this change might not actually fix the issue with tusky because "" isn't a valid iso8601 date either, will change that tomorrow

Okay just swinging by and saying that this change might not actually fix the issue with tusky because "" isn't a valid iso8601 date either, will change that tomorrow
darkkirb added 1 commit 2023-01-08 08:16:53 +00:00
Replace invalid/unsupported dates with with epoch
Some checks are pending
ci/woodpecker/pr/woodpecker Pipeline is pending
8d55b8c6d9
Masto API requires “ISO 8601 Datetime”, not “ISO 8601 Datetime or empty”

it's not perfect, but if it removes stuff that causes issues with client apps, that's all good

thanks a lot for looking into it!

it's not perfect, but if it removes stuff that causes issues with client apps, that's all good thanks a lot for looking into it!
floatingghost merged commit a8cd859ef9 into develop 2023-01-09 22:12:29 +00:00
floatingghost deleted branch fix-invalid-datetime 2023-01-09 22:12:29 +00:00
Sign in to join this conversation.
No description provided.