forgejo/templates/repo/release
0ko 2382b74526 feat(ui): add MIME types for generated archives (#6959)
* add MIME types `application/zip` and `application/gzip` to anchors of automatically generated archives.
* add testing for that, and also for https://codeberg.org/forgejo/forgejo/pulls/2899

## Why

Many instances are struggling with crawlers that are fetching these links, causing archives to be generated. The content is actually never downloaded.

[MDN describes](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#type) this attribute as a "hint". So this hint can help a client to decide against fetching the href contents. I don't believe this change will actually improve the situation, however, I think this attribute is nice to have.

## MIME types

It was a bit difficult to determine which are the right ones for this use case.
[IANA lists](https://www.iana.org/assignments/media-types/media-types.xhtml) both `application/zip` and `application/gzip`.
`application/zip` refers to [RFC6713](https://datatracker.ietf.org/doc/html/rfc6713) and `application/gzip` doesn't refer to an RFC directly. It also has [detailed information](https://www.iana.org/assignments/media-types/application/zip) about zip. [gzip is less detailed](https://www.iana.org/assignments/media-types/application/gzip).

* [`application/zip`](https://www.iana.org/assignments/media-types/application/zip):
    > ZIP files are binary data and thus should be encoded for MIME mail
transmission.

    This was written in 1993, but probably applies to the more modern web as well.
* [`application/gzip`](https://datatracker.ietf.org/doc/rfc6713):
    > The 'application/gzip' media type describes a block of data that is
   compressed using gzip [RFC1952] compression.  The data is a stream of
   bytes as described in RFC 1952.

    [RFC1952](https://datatracker.ietf.org/doc/rfc1952/) is a "GZIP file format specification", but there's a warning: "This RFC is not endorsed by the IETF and has no formal standing in the IETF standards process.". Anyway, I consider it as the right way to mark .tar.gz files too.

Additional stuff that I read while researching:
* https://stackoverflow.com/questions/2110269/add-mime-type-to-html-link

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/6959
Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org>
Reviewed-by: Otto <otto@codeberg.org>
Co-authored-by: 0ko <0ko@noreply.codeberg.org>
Co-committed-by: 0ko <0ko@noreply.codeberg.org>
2025-02-16 12:59:28 +00:00
..
list.tmpl feat(ui): add MIME types for generated archives (#6959) 2025-02-16 12:59:28 +00:00
new.tmpl templates: release: Add JS to set default release title to tag name (#6645) 2025-02-02 12:00:52 +00:00