mirror of
1
Fork 0
forgejo/templates/repo
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
..
actions Fix incomplete Actions status aggregations (#32859) 2024-12-22 08:46:38 +01:00
branch [PORT] Refactor DateUtils and merge TimeSince (gitea#32409) 2024-11-10 22:23:27 +01:00
cite ui: fix go to citation button url (#4597) 2024-08-22 15:36:12 +00:00
code [PORT] Refactor DateUtils and merge TimeSince (gitea#32409) 2024-11-10 22:23:27 +01:00
diff ui: update styling of comment headers and role labels (#6816) 2025-02-07 01:07:16 +00:00
editor fix(i18n): add forgotten translatable string (#6701) 2025-01-29 07:45:40 +00:00
find
graph [PORT] Refactor DateUtils and merge TimeSince (gitea#32409) 2024-11-10 22:23:27 +01:00
issue feat(ui): Display to maintainers in PR when it is editable 2025-02-09 16:22:25 +01:00
migrate Added `alt`'s to `<img>` 2025-01-31 21:22:00 +00:00
projects
pulls
release feat(ui): add MIME types for generated archives (#6959) 2025-02-16 12:59:28 +00:00
settings Added `alt`'s to `<img>` 2025-01-31 21:22:00 +00:00
tag [PORT] Refactor DateUtils and merge TimeSince (gitea#32409) 2024-11-10 22:23:27 +01:00
wiki Cap wiki search width at 80% container width 2024-11-25 09:51:26 +01:00
activity.tmpl
admin_flags.tmpl
blame.tmpl
branch_dropdown.tmpl Revert "add gap between branch dropdown and PR button" 2024-10-21 15:21:44 +02:00
clone_buttons.tmpl
clone_script.tmpl
code_frequency.tmpl
commit_load_branches_and_tags.tmpl
commit_page.tmpl fix(ui): display verified icon for default gpg key (#6803) 2025-02-07 12:30:25 +00:00
commit_status.tmpl
commit_statuses.tmpl
commits.tmpl
commits_list.tmpl feat: Allow opening a single-file diff from file history view (#6599) 2025-02-05 17:43:27 +00:00
commits_list_small.tmpl
commits_search_dropdown.tmpl
commits_table.tmpl
contributors.tmpl Add "n commits" link to contributors in contributors graph page (#32799) 2024-12-15 13:21:02 +01:00
create.tmpl New repo: Rework initialization 2024-12-29 13:05:30 +01:00
create_advanced.tmpl New repo: Rework advanced and template sections 2024-12-28 22:32:19 +01:00
create_basic.tmpl New repo: Rework advanced and template sections 2024-12-28 22:32:19 +01:00
create_from_template.tmpl New repo: Rework advanced and template sections 2024-12-28 22:32:19 +01:00
create_helper.tmpl
create_init.tmpl New repo: Rework initialization 2024-12-29 13:05:30 +01:00
empty.tmpl [PORT] Refactor DateUtils and merge TimeSince (gitea#32409) 2024-11-10 22:23:27 +01:00
file_info.tmpl [UI] Adjust trailing EOL behavior for empty file 2024-08-19 20:23:15 +02:00
flags.tmpl
forks.tmpl
graph.tmpl Use redesigned switch on commit graph page (#6545) 2025-01-13 17:20:32 +00:00
header.tmpl ui: simplify main-attribute labels 2024-12-08 17:30:52 +05:00
header_fork.tmpl
home.tmpl feat: filepath filter for code search (#6143) 2024-12-22 12:24:29 +00:00
icon.tmpl
latest_commit.tmpl fix: enlargen gap between avatar and name 2024-08-14 17:19:23 +02:00
navbar.tmpl
packages.tmpl
pulse.tmpl [PORT] Refactor DateUtils and merge TimeSince (gitea#32409) 2024-11-10 22:23:27 +01:00
recent_commits.tmpl
release_tag_header.tmpl feat: Add Search to Releases Page 2024-11-02 10:24:35 +01:00
search.tmpl ui(code-search): fix to use CodeSearchMode 2024-09-16 16:20:55 +02:00
search_name.tmpl
shabox_badge.tmpl
star_unstar.tmpl
sub_menu.tmpl ui: update language stats layout and click behavior (#6700) 2025-01-29 16:55:10 +00:00
unicode_escape_prompt.tmpl
upload.tmpl
user_cards.tmpl [PORT] Refactor DateUtils and merge TimeSince (gitea#32409) 2024-11-10 22:23:27 +01:00
view_file.tmpl [PORT] Refactor DateUtils and merge TimeSince (gitea#32409) 2024-11-10 22:23:27 +01:00
view_list.tmpl [PORT] Refactor DateUtils and merge TimeSince (gitea#32409) 2024-11-10 22:23:27 +01:00
watch_unwatch.tmpl
watchers.tmpl