# HG changeset patch # User Thomas De Schampheleire # Date 1548530870 -3600 # Node ID e74aa69f6827e1f6da4ae94ea2bcac10c98d0203 # Parent 81db5704b2859c5dd4d0309acb80a4a9d41c7600 lib: sanitize HTML for all types of README rendering, not only markdown The repository summary page will display a rendered version of the repository 'readme' based on its file extension. In commit 5746cc3b3fa5, the rendered output was already sanitized when the input was markdown. However, also readmes written in other formats, like ReStructuredText (RST) or plain text could have content that we want sanitized. Therefore, move the sanitizing one level up so it covers all renderers, for now and the future. This fixes an XSS issue when a repository readme contains javascript code, which would be executed when the repository summary page is visited by a user. Reported by Bob Hogg (thanks!). diff -r 81db5704b285 -r e74aa69f6827 kallithea/lib/markup_renderer.py --- a/kallithea/lib/markup_renderer.py Sat Jan 26 20:00:14 2019 +0100 +++ b/kallithea/lib/markup_renderer.py Sat Jan 26 20:27:50 2019 +0100 @@ -125,7 +125,19 @@ renderer = self._detect_renderer(source, filename) readme_data = renderer(source) - return readme_data + # Allow most HTML, while preventing XSS issues: + # no