commit 92c8ec640028151d1e92eaef79c4fcd1365998bc from: Omar Polo date: Tue Jan 03 15:02:26 2023 UTC gotwebd: use Content-Disposition for RSS; sets the filename Since gotwebd serves the RSS from a path without a file name component, browsers just make up a random string to give the file a name which can be confusing. Furthermore, since it's served as application/rss+xml they try to render the XML (failing.) Use gotweb_render_content_type_file (which sets the Content-Disposition HTTP header) to fix both: the feed is now called .rss and set as attachment (thus saved and not rendered.) Change the function to take an optional filename suffix for the occasion. ok jamsek commit - 2be11cdeee0c210d3273b3724e924de0422d9f67 commit + 92c8ec640028151d1e92eaef79c4fcd1365998bc blob - 89718fdd602637e74ca5a949af1e7cfda57b723d blob + 87cec74f0c075ba839a114bdb6c50bdca8ae9160 --- gotwebd/got_operations.c +++ gotwebd/got_operations.c @@ -1044,7 +1044,7 @@ got_output_file_blob(struct request *c) if (isbinary(buf, len - hdrlen)) { error = gotweb_render_content_type_file(c, "application/octet-stream", - qs->file); + qs->file, NULL); if (error) { log_warnx("%s: %s", __func__, error->msg); blob - 6f5a07850b9e8e153830292e5ce4f4d986782eff blob + 71c0cc53686a79ce8460d54182ee5f79b42fe117 --- gotwebd/gotweb.c +++ gotwebd/gotweb.c @@ -179,8 +179,9 @@ gotweb_process_request(struct request *c) } if (qs->action == RSS) { - error = gotweb_render_content_type(c, - "application/rss+xml;charset=utf-8"); + error = gotweb_render_content_type_file(c, + "application/rss+xml;charset=utf-8", + repo_dir->name, ".rss"); if (error) { log_warnx("%s: %s", __func__, error->msg); goto err; @@ -670,11 +671,11 @@ gotweb_render_content_type(struct request *c, const ui const struct got_error * gotweb_render_content_type_file(struct request *c, const char *type, - const char *file) + const char *file, const char *suffix) { fcgi_printf(c, "Content-type: %s\r\n" - "Content-disposition: attachment; filename=%s\r\n\r\n", - type, file); + "Content-disposition: attachment; filename=%s%s\r\n\r\n", + type, file, suffix ? suffix : ""); return NULL; } blob - 8a9deffd75b83126733cb4d76bb9170bc7604995 blob + 2e636f2ae10ecc8792581ba3ec50726f33ca127f --- gotwebd/gotwebd.h +++ gotwebd/gotwebd.h @@ -437,7 +437,7 @@ const struct got_error *gotweb_render_content_type(str const uint8_t *); const struct got_error *gotweb_render_content_type_file(struct request *, const char *, - const char *); + const char *, const char *); void gotweb_get_navs(struct request *, struct gotweb_url *, int *, struct gotweb_url *, int *); const struct got_error *gotweb_get_time_str(char **, time_t, int);