This PHP regex will match any string that contains Indic character combinations known to crash many iOS applications as of 11.2.5 and certain macOS combinations as of 10.13.3. The crash occurs in CoreText.
This regex will only work if you use the x
and u
modifiers. Example: "{regex-goes-here}xu"
While PHP does use PCRE, the u
modifier isn't technically Perl-compatible. For this to work without the u
modifier, the regex would need to be adapted to use | instead of [], as all of these characters are multibyte in all popular web encodings, e.g. UTF-8.
Tracked By: rdar://37458268 Date Originated: 2018-02-12 CVE ID: Unknown as of writing
Adapted for PHP by Paul Buonopane of NamePros.
Based heavily on the following works:
The license for the work on which this regex is based is provided below, with an additional note regarding adaptation.
Copyright 2018 hackbunny <hackbunny@gmail.com> Adapted for PHP by Paul Buonopane
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.