Page MenuHomePhabricator

Limit remarkup URI protocol length to 32 characters to avoid expensive regex behavior
ClosedPublic

Authored by epriestley on Feb 17 2021, 9:12 PM.
Tags
None
Referenced Files
F15188018: D21562.diff
Fri, Feb 21, 12:27 PM
Unknown Object (File)
Wed, Feb 19, 8:28 PM
Unknown Object (File)
Wed, Feb 19, 5:44 PM
Unknown Object (File)
Wed, Feb 19, 5:44 PM
Unknown Object (File)
Wed, Feb 19, 5:44 PM
Unknown Object (File)
Wed, Feb 19, 5:44 PM
Unknown Object (File)
Sun, Feb 16, 9:01 PM
Unknown Object (File)
Fri, Feb 14, 7:40 PM
Subscribers
None

Details

Summary

Ref T13608. When searching for bare URIs in remarkup text, don't look for URIs with a protocol string longer than 32 characters.

This avoids a case where the regexp engine may be tricked into executing at O(N^2) or some similar complexity.

Test Plan
  • Applied remarkup to "AAAA..." (512KB).
  • Before: 64 seconds to process.
  • After: <10ms to process.
  • Ran unit tests.

Diff Detail

Repository
rP Phabricator
Lint
Lint Not Applicable
Unit
Tests Not Applicable