Diff options
| author | Bryce Kwon <bryce@brycekwon.com> | |
|---|---|---|
| committer | Bryce Kwon <bryce@brycekwon.com> | |
| commit | ||
| parent | ||
| tree | ||
| download | ||
Drop cached pages asked for with an escaped url
README tells a visitor to write a plus in the query form as %2b, and
cgit caches such a page under the raw query, but the hook compared that
query with the url as it stands. A push to foo+bar.git left its pages
under url=foo%2bbar.git/ and r=foo%2Bbar.git cached and stale until
their ttl ran out. Decoding in sh would take more than the hook is
worth, so a query with a % or a + now counts as stale, which costs
another repository's page at most a refill.
Diffstat (limited to 'custom/hooks/post-receive.cgit-cache')
| -rwxr-xr-x | custom/hooks/post-receive.cgit-cache | 10 |
1 file changed, 7 insertions, 3 deletions
diff --git a/custom/hooks/post-receive.cgit-cache b/custom/hooks/post-receive.cgit-cache index 8aae60b..b92683a 100755 --- a/custom/hooks/post-receive.cgit-cache +++ b/custom/hooks/post-receive.cgit-cache @@ -7,8 +7,9 @@ # cgit writes the request each slot answers at the head of the slot file, so # the hook reads it back and drops only this repository's pages and the # repository index, whose idle column the push changes. Other repositories -# keep their cached pages. The cached repository scan goes too, which is what -# makes a brand new repository appear without waiting out cache-scan-ttl. +# keep their cached pages, bar any asked for with an escaped query. The cached +# repository scan goes too, which is what makes a brand new repository appear +# without waiting out cache-scan-ttl. # # The hook needs the url cgit serves this repository at. A repository that # scan-path finds is served at its path below scan_path, as set below, so @@ -77,7 +78,8 @@ take() { # Whether the page a slot holds goes stale with this push: one of this # repository's, by path or by the url and r parameters, or the index. A key # that does not read as cgit's counts as stale, since dropping a page costs -# only a refill. +# only a refill, and so does a query with a % or a + in it, since only +# decoding it would tell which repository it names. stale() { rest=$1 take && take && take || return 0 @@ -99,6 +101,8 @@ stale() { ;; *"&url=&"* | *"&url=/&"*) ;; + *"&url="*[%+]* | *"&r="*[%+]*) + ;; *"&url="* | *"&r="*) return 1 ;; |
