From: Mark Jamsek Subject: Re: gotwebd: set filename for RSS feeds To: Omar Polo Cc: gameoftrees@openbsd.org Date: Tue, 3 Jan 2023 22:43:26 +1100 On 23-01-03 12:22PM, Omar Polo wrote: > a consequence i haven't realized when adding RSS support is that since > gotwebd serves the pages from a path that's lacking a filename part, > the browser call the RSS feed with a random string. > > This is not an issue for RSS readers (they extract all the needed info > from the XML), but it's ugly, so let's fix it. > > Diff below uses Content-Disposition to 1) make the browser download > the file instead of rendering it and 2) use a reasonable file name > (got.git.rss) instead of the random string the browser will use > otherwise (lHFP5B6d). > > ok? good catch! nice. ok > diff /home/op/w/got2 > commit - 1b18f4cd75fddf070589d9b045e083ac02d8baba > path + /home/op/w/got2 > blob - 6f5a07850b9e8e153830292e5ce4f4d986782eff > file + gotwebd/gotweb.c > --- gotwebd/gotweb.c > +++ gotwebd/gotweb.c > @@ -179,8 +179,13 @@ gotweb_process_request(struct request *c) > } > > if (qs->action == RSS) { > - error = gotweb_render_content_type(c, > - "application/rss+xml;charset=utf-8"); > + char feedname[PATH_MAX]; > + > + strlcpy(feedname, repo_dir->name, sizeof(feedname)); > + strlcat(feedname, ".rss", sizeof(feedname)); > + > + error = gotweb_render_content_type_file(c, > + "application/rss+xml;charset=utf-8", feedname); > if (error) { > log_warnx("%s: %s", __func__, error->msg); > goto err; > -- Mark Jamsek GPG: F2FF 13DE 6A06 C471 CA80 E6E2 2930 DC66 86EE CF68