]> Lady’s Gitweb - Gitweb/commit
gitweb: Serve */*+xml 'blob_plain' as text/plain with $prevent_xss
authorJakub Narebski <redacted>
Thu, 30 Jun 2011 09:39:21 +0000 (11:39 +0200)
committerLady <redacted>
Mon, 6 Apr 2026 04:51:31 +0000 (00:51 -0400)
commitd0a0ccb4d27d63a2fb051d330f0b7be40f79cfac59125cc6bef13cd764bb6656
tree3058de1ba6d2be7320d9e3c57f7c01c0956bf9742b090ff168361b945c3a5fb9
parentb62b94d2c6dc37b4ab40aa5af97e770794b47187178c62761e57e7794f7d2f31
gitweb: Serve */*+xml 'blob_plain' as text/plain with $prevent_xss

Enhance usability of 'blob_plain' view protection against XSS attacks
(enabled by setting $prevent_xss to true) by serving contents inline
as safe 'text/plain' mimetype where possible, instead of serving with
"Content-Disposition: attachment" to make sure they don't run in
gitweb's security domain.

This patch broadens downgrading to 'text/plain' further, to any
*/*+xml mimetype.  This includes:

  application/xhtml+xml    (*.xhtml, *.xht)
  application/atom+xml     (*.atom)
  application/rss+xml      (*.rss)
  application/mathml+xm    (*.mathml)
  application/docbook+xml  (*.docbook)
  image/svg+xml            (*.svg, *.svgz)

Probably most useful is serving XHTML files as text/plain in
'blob_plain' view, directly viewable.

Because file with 'image/svg+xml' mimetype can be compressed SVGZ
file, we have to check if */*+xml really is text file, via '-T $fd'.

Signed-off-by: Jakub Narebski <redacted>
Signed-off-by: Junio C Hamano <redacted>
gitweb.perl
This page took 0.271048 seconds and 4 git commands to generate.