commit d7034a4ea257e654c3ac01eae64452461d31d233 from: Omar Polo via: Thomas Adam date: Fri Jan 06 09:33:00 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 - 77d755e8ee27002658ec8f9ed0a282ac89d2906f commit + d7034a4ea257e654c3ac01eae64452461d31d233 blob - 40e8ef26d1b28b601ac2a1af3b4f766a63e48ece blob + adaba67ceee3e64ece4fc51654ac750358bfc1b2 --- 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 - 6017208e29d944a6b739e580b432aaf6eb981794 blob + efbd65db33afe8b913df52cf9c6ded70308705b8 --- gotwebd/gotweb.c +++ gotwebd/gotweb.c @@ -180,8 +180,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; @@ -671,11 +672,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 - fe2a573ae72fdc13b28304d46671fcdba77efd64 blob + 3c805ab5bb454c73db3f42dc2068c27fe2897265 --- gotwebd/gotwebd.h +++ gotwebd/gotwebd.h @@ -439,7 +439,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);