Skip to content

Commit 498cb5c

Browse files
author
epriestley
committedJul 2, 2016
Fix an XSS issue where Diffusion files exceeding the highlighting byte limit were not properly escaped
Fixes T11257. Auditors: chad
1 parent ceb395e commit 498cb5c

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed
 

‎src/applications/diffusion/controller/DiffusionBrowseController.php

+8-4
Original file line numberDiff line numberDiff line change
@@ -682,17 +682,21 @@ private function buildCorpus(
682682
$blame_commits,
683683
$show_blame);
684684
} else {
685-
if ($can_highlight) {
686-
require_celerity_resource('syntax-highlighting-css');
685+
require_celerity_resource('syntax-highlighting-css');
687686

687+
if (!$can_highlight) {
688688
$highlighted = PhabricatorSyntaxHighlighter::highlightWithFilename(
689689
$path,
690690
$file_corpus);
691-
$lines = phutil_split_lines($highlighted);
692691
} else {
693-
$lines = phutil_split_lines($file_corpus);
692+
// Highlight as plain text to escape the content properly.
693+
$highlighted = PhabricatorSyntaxHighlighter::highlightWithLanguage(
694+
'txt',
695+
$file_corpus);
694696
}
695697

698+
$lines = phutil_split_lines($highlighted);
699+
696700
$rows = $this->buildDisplayRows(
697701
$lines,
698702
$blame_list,

0 commit comments

Comments
 (0)
Failed to load comments.