Page MenuHomePhabricator

Fix an issue where prose diffing may fail after hitting the PCRE backtracking limit
ClosedPublic

Authored by epriestley on Jul 23 2020, 2:40 PM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Apr 25, 2:29 AM
Unknown Object (File)
Thu, Apr 25, 2:07 AM
Unknown Object (File)
Mon, Apr 22, 9:21 AM
Unknown Object (File)
Sat, Apr 20, 12:21 PM
Unknown Object (File)
Wed, Mar 27, 12:38 PM
Unknown Object (File)
Mar 26 2024, 12:59 AM
Unknown Object (File)
Feb 6 2024, 11:01 PM
Unknown Object (File)
Jan 9 2024, 8:05 AM
Subscribers
None

Details

Summary

Fixes T13554. For certain prose diff inputs and PCRE backtracking limits, this regular expression may back track too often and fail.

A characteristic input is "x x x x ...", i.e. many sequences where (.*?)\s*\z looks like it may be able to match but actually can not.

I think writing an expression which has all the behavior we'd like without this backtracking issue isn't trivial (at least, I don't think I know how to do it offhand); just use a strategy based on "trim()" insetad, which avoids any PCRE complexities here.

Test Plan

Locally, this passes the "x x x ..." test which the previous code failed. I'm not including that test because it won't reproduce across values of "pcre.backtrac_limit", PCRE versions, etc.

Diff Detail

Repository
rP Phabricator
Branch
prosediff1
Lint
Lint Passed
Unit
Tests Passed
Build Status
Buildable 24792
Build 34201: Run Core Tests
Build 34200: arc lint + arc unit

Event Timeline

This revision was not accepted when it landed; it landed in state Needs Review.Jul 23 2020, 2:46 PM
This revision was automatically updated to reflect the committed changes.