Page MenuHomePhabricator

Fall back to slow UTF8 algorithms that don't crash
ClosedPublic

Authored by epriestley on Jun 11 2014, 2:02 PM.

Details

Summary

Fixes T5316. PCRE can blow stacks on (x|y)+ regexps, and a user is hitting a consistent fatal in PCRE.

Rewrite the fallback for phutil_is_utf8() to be iterative. This is somewhat slower, but not normally too horrible, and we have a variety of ways to mitigate that if it arises as a real issue (encourage installation of mb extension, ship a fast C extension, etc).

We already have most of this code anyway.

Test Plan

We have fairly good test coverage here already, I mostly just realigned the existing test coverage to explicitly call the new code.

Diff Detail

Repository
rPHU libphutil
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

epriestley retitled this revision from to Fall back to slow UTF8 algorithms that don't crash.
epriestley updated this object.
epriestley edited the test plan for this revision. (Show Details)
epriestley added a reviewer: btrahan.
  • Tweak an old, slightly misleading comment.

Tested and works for me on the changeset that was displaying this issue. It did prompt to mark 2 of the files in the diff as binary, but allowed the revision to be posted.

btrahan edited edge metadata.

You are much smarter than my baby.

This revision is now accepted and ready to land.Jun 20 2014, 5:19 PM
epriestley updated this revision to Diff 23141.

Closed by commit rPHUf1e0aedec85b (authored by @epriestley).