Commits

Remy Blank committed f28f597

versioncontrol: For `export:` links, use `HEAD` to reference the youngest revision in the URL instead of an empty path component, and prevent caching.

Closes #9264.

  • Participants
  • Parent commits 9f9d8d2

Comments (0)

Files changed (2)

File trac/versioncontrol/web_ui/browser.py

             req.redirect(go_to_preselected)
 
         path = req.args.get('path', '/')
-        rev = req.args.get('rev', None)
+        rev = req.args.get('rev', '')
+        if rev in ('', 'HEAD'):
+            rev = None
         order = req.args.get('order', 'name').lower()
         desc = req.args.has_key('desc')
         xhr = req.get_header('X-Requested-With') == 'XMLHttpRequest'
                             format == 'txt' and 'text/plain' or mime_type)
             req.send_header('Content-Length', node.content_length)
             req.send_header('Last-Modified', http_date(node.last_modified))
+            if rev is None:
+                req.send_header('Pragma', 'no-cache')
+                req.send_header('Cache-Control', 'no-cache')
+                req.send_header('Expires', 'Fri, 01 Jan 1999 00:00:00 GMT')
             if not self.render_unsafe_content:
                 # Force browser to download files instead of rendering
                 # them, since they might contain malicious code enabling 
         elif '@' in export:
             path, rev = export.split('@', 1)
         else:
-            rev, path = '', export
+            rev, path = 'HEAD', export
         return tag.a(label, class_='export',
                      href=formatter.href.export(rev, path) + fragment)
 

File trac/versioncontrol/web_ui/tests/wikisyntax.py

 export:/foo/pict.gif@123
 ------------------------------
 <p>
-<a class="export" href="/export//foo/bar.html">export:/foo/bar.html</a>
+<a class="export" href="/export/HEAD/foo/bar.html">export:/foo/bar.html</a>
 <a class="export" href="/export/123/foo/pict.gif">export:123:/foo/pict.gif</a>
 <a class="export" href="/export/123/foo/pict.gif">export:/foo/pict.gif@123</a>
 </p>
 export:/foo/bar.html#header
 ------------------------------
 <p>
-<a class="export" href="/export//foo/bar.html#header">export:/foo/bar.html#header</a>
+<a class="export" href="/export/HEAD/foo/bar.html#header">export:/foo/bar.html#header</a>
 </p>
 ------------------------------
 """ # " (be Emacs friendly...)