Commit 09e770d
committed
Fix GH-14481: realpath() and SplFileInfo::getRealPath inside Phar
realpath() and SplFileInfo::getRealPath() route directly through
VCWD_REALPATH, which has no notion of stream wrappers. For a phar://
URL the call chain treats the URI as relative, prepends CWD, and
stat()s a nonsense path, so existing entries inside a Phar return
false even though file_exists()/is_file()/include all see them.
Before VCWD_REALPATH, look up the stream wrapper for the path. If a
non-plain, non-URL wrapper supplies url_stat and reports SUCCESS,
return the input string; on FAILURE, return false. Plain paths (and
file:// URLs that resolve back to the plain-files wrapper) keep the
existing VCWD_REALPATH semantics: realpath cache, ZTS access guard,
and open_basedir check. For phar URLs, open_basedir is enforced by
the wrapper's own url_stat, matching how is_file() and file_exists()
behave today.
The !wrapper->is_url guard keeps URL-style wrappers (http://, ftp://,
data://, user wrappers registered with STREAM_IS_URL) on the existing
false return so realpath() does not gain network or third-party
url_stat side effects. In-tree, only phar matches the new branch.
User wrappers registered without STREAM_IS_URL that implement
url_stat will now have url_stat called from realpath().
PharFileInfo, SplFileObject, DirectoryIterator,
RecursiveDirectoryIterator, and FilesystemIterator inherit
SplFileInfo::getRealPath and pick up the fix.
Closes GH-144811 parent bd78496 commit 09e770d
3 files changed
Lines changed: 82 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1244 | 1244 | | |
1245 | 1245 | | |
1246 | 1246 | | |
| 1247 | + | |
| 1248 | + | |
| 1249 | + | |
| 1250 | + | |
| 1251 | + | |
| 1252 | + | |
| 1253 | + | |
| 1254 | + | |
| 1255 | + | |
| 1256 | + | |
| 1257 | + | |
1247 | 1258 | | |
1248 | 1259 | | |
1249 | 1260 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2102 | 2102 | | |
2103 | 2103 | | |
2104 | 2104 | | |
| 2105 | + | |
| 2106 | + | |
| 2107 | + | |
| 2108 | + | |
| 2109 | + | |
| 2110 | + | |
| 2111 | + | |
| 2112 | + | |
| 2113 | + | |
| 2114 | + | |
2105 | 2115 | | |
2106 | 2116 | | |
2107 | 2117 | | |
| |||
0 commit comments