CRM_Utils_File::isChildPath - Fix checking of non-existent paths
authorTim Otten <totten@civicrm.org>
Wed, 10 Nov 2021 02:31:05 +0000 (18:31 -0800)
committerTim Otten <totten@civicrm.org>
Wed, 10 Nov 2021 02:50:23 +0000 (18:50 -0800)
commit8226356b7bd3874bc1bba55d9ec8e32d1de8ebe1
treea2cd8f3a906141468ac846a63de68cb394172e8e
parentcd827fb2074718a8d334e0cba696ad71cce23274
CRM_Utils_File::isChildPath - Fix checking of non-existent paths

Suppose you use call `isChildPath()` with these options:

* `$parent='/nonexistent'`
* `$child='/home/me/exists.txt'`
* `$checkRealPath=TRUE`

Before
=====

Reports that `/home/me/exists.txt` is a child of `/nonexistent`

After
=====

Reports that `/home/me/exists.txt` is NOT a child of `/nonexistent`

Comments
========

I added six test cases for how `isChildPath()` behaves when using
`$checkRealPath=TRUE`.  The first five cases behave the same with or without
the patch.  The patch fixes the last case.
CRM/Utils/File.php
tests/phpunit/CRM/Utils/FileTest.php