Page MenuHomePhabricator

Prevent Pygments from flying off the rails too aggressively
ClosedPublic

Authored by epriestley on Dec 5 2018, 7:15 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Dec 16, 4:46 AM
Unknown Object (File)
Mon, Dec 16, 4:46 AM
Unknown Object (File)
Mon, Dec 16, 4:46 AM
Unknown Object (File)
Tue, Dec 10, 9:48 AM
Unknown Object (File)
Fri, Nov 29, 1:45 PM
Unknown Object (File)
Wed, Nov 27, 3:09 AM
Unknown Object (File)
Sat, Nov 23, 10:49 AM
Unknown Object (File)
Tue, Nov 19, 11:02 AM
Subscribers
None

Details

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.

Diff Detail

Repository
rPHU libphutil
Branch
pygments1
Lint
Lint Passed
Unit
Tests Passed
Build Status
Buildable 21247
Build 28899: Run Core Tests
Build 28898: arc lint + arc unit