Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attachment filenames think today is next year #5932

Open
3 tasks done
gwymor opened this issue Dec 31, 2024 · 0 comments
Open
3 tasks done

Attachment filenames think today is next year #5932

gwymor opened this issue Dec 31, 2024 · 0 comments

Comments

@gwymor
Copy link

gwymor commented Dec 31, 2024

  • I have searched open and closed issues for duplicates
  • I am submitting a bug report for existing functionality that does not work as intended
  • This isn't a feature request or a discussion topic

Bug description

Starting on Monday, 30 December 2024, until the beginning of 2025, attachments sent from Signal iOS which get automatic signal-... filenames erroneously write the year as 2025 instead of 2024. This bug does not seem to occur when sending from Signal Android.

I believe this is because Signal iOS is not actually getting the year number, but the year associated with the ISO week number. As the majority of the days in the week of 30 December (starting on Monday) are in 2025, the ISO week date calendar considers the week as the first of 2025, rather than the last of 2024:

$ date +%F
2024-12-31
$ date +%G-W%V
2025-W01

Relevant code (as far as I can tell) in SignalServiceKit/Attachments/SignalAttachment.swift:

    // Use the filename if known. If not, e.g. if the attachment was copy/pasted, we'll generate a filename
    // like: "signal-2017-04-24-095918.zip"
    public var filenameOrDefault: String {
        if let filename = sourceFilename {
            return filename.filterFilename()
        } else {
            let kDefaultAttachmentName = "signal"

            let dateFormatter = DateFormatter()
            dateFormatter.dateFormat = "YYYY-MM-dd-HHmmss"
            let dateString = dateFormatter.string(from: Date())

            let withoutExtension = "\(kDefaultAttachmentName)-\(dateString)"
            if let fileExtension = self.fileExtension {
                return "\(withoutExtension).\(fileExtension)"
            }

            return withoutExtension
        }
    }

See Apple's documentation:

A common mistake is to use YYYY. yyyy specifies the calendar year whereas YYYY specifies the year (of “Week of Year”), used in the ISO year-week calendar. In most cases, yyyy and YYYY yield the same number, however they may be different. Typically you should use the calendar year.

Steps to reproduce

  • On Signal iOS, send an image that will get recompressed or converted, between 30 December 2024 and the beginning of 2025
  • On any Signal app, download the image from the conversation

Actual result: The file is named like signal-2025-12-31-012345.jpeg

Expected result: The file is named like signal-2024-12-31-012345.jpeg

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant