Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15308885
D19847.id47396.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
980 B
Referenced Files
None
Subscribers
None
D19847.id47396.diff
View Options
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
Details
Attached
Mime Type
text/plain
Expires
Mar 7 2025, 6:45 AM (5 w, 11 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7324755
Default Alt Text
D19847.id47396.diff (980 B)
Attached To
Mode
D19847: Prevent Pygments from flying off the rails too aggressively
Attached
Detach File
Event Timeline
Log In to Comment