Prevent Pygments from flying off the rails too aggressively

Authored by epriestley <git@epriestley.com> on Wed, Dec 5, 8:10 PM.

Description

Prevent Pygments from flying off the rails too aggressively

Summary:
Ref T13224. For some inputs, Pygments has explosive runtime (e.g., 3+ minutes on a 70-character input to the Bash highlighter).

For now, at least limit the maximum amount of damage this can cause. If pygmentize runs for more than 15 seconds, kill it and decline to highlight the file.

In the future, I'd like to take more steps like: fix the Pygments upstream; port more highlighters to PHP; surface this error to the user explicitly.

Test Plan: Tried to highlight echo "\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ as Bash, no more infinite pygmentize.

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T13224

Differential Revision: https://secure.phabricator.com/D19847

Details

Committed
epriestley <git@epriestley.com>Thu, Dec 6, 4:46 PM
Parents
rLIBPHUTIL35d0ec2dfa59: Keep the new "%P" query conversion out of the service call profiler by…
Branches
Unknown
Tags
Unknown
epriestley <git@epriestley.com> committed rLIBPHUTIL1e590fd9e58e: Prevent Pygments from flying off the rails too aggressively (authored by epriestley <git@epriestley.com>).Thu, Dec 6, 4:46 PM