Page MenuHomePhabricator

D19847.id47396.diff
No OneTemporary

D19847.id47396.diff

diff --git a/src/markup/syntax/highlighter/PhutilPygmentsSyntaxHighlighter.php b/src/markup/syntax/highlighter/PhutilPygmentsSyntaxHighlighter.php
--- a/src/markup/syntax/highlighter/PhutilPygmentsSyntaxHighlighter.php
+++ b/src/markup/syntax/highlighter/PhutilPygmentsSyntaxHighlighter.php
@@ -24,12 +24,20 @@
$future = new ExecFuture(
'pygmentize -O encoding=utf-8 -O stripnl=False -f html -l %s',
$language);
+
$scrub = false;
if ($language == 'php' && strpos($source, '<?') === false) {
$source = "<?php\n".$source;
$scrub = true;
}
+
+ // See T13224. In some cases, "pygmentize" has explosive runtime on small
+ // inputs. Put a hard cap on how long it is allowed to run for to limit
+ // the amount of damage it can do.
+ $future->setTimeout(15);
+
$future->write($source);
+
return new PhutilDefaultSyntaxHighlighterEnginePygmentsFuture(
$future,
$source,

File Metadata

Mime Type
text/plain
Expires
Mon, May 20, 1:12 AM (2 w, 8 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6269402
Default Alt Text
D19847.id47396.diff (980 B)

Event Timeline