1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-28 09:42:41 +01:00

(stable) Fix an XSS issue where Diffusion files exceeding the highlighting byte limit were not properly escaped

Fixes T11257.

Auditors: chad
This commit is contained in:
epriestley 2016-07-02 05:17:05 -07:00
parent a31815bc1c
commit fd33fbbfae

View file

@ -682,17 +682,21 @@ final class DiffusionBrowseController extends DiffusionController {
$blame_commits, $blame_commits,
$show_blame); $show_blame);
} else { } else {
if ($can_highlight) {
require_celerity_resource('syntax-highlighting-css'); require_celerity_resource('syntax-highlighting-css');
if (!$can_highlight) {
$highlighted = PhabricatorSyntaxHighlighter::highlightWithFilename( $highlighted = PhabricatorSyntaxHighlighter::highlightWithFilename(
$path, $path,
$file_corpus); $file_corpus);
$lines = phutil_split_lines($highlighted);
} else { } else {
$lines = phutil_split_lines($file_corpus); // Highlight as plain text to escape the content properly.
$highlighted = PhabricatorSyntaxHighlighter::highlightWithLanguage(
'txt',
$file_corpus);
} }
$lines = phutil_split_lines($highlighted);
$rows = $this->buildDisplayRows( $rows = $this->buildDisplayRows(
$lines, $lines,
$blame_list, $blame_list,