Skip to content

Commit 49ae6f9

Browse files
authored
Update JsonFile.php
- Removed realpath function
1 parent 9baeecc commit 49ae6f9

File tree

1 file changed

+1
-15
lines changed

1 file changed

+1
-15
lines changed

src/JsonFile.php

+1-15
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,6 @@ class JsonFile
1717
*/
1818
public function read($file)
1919
{
20-
// Sanitize the file path
21-
$file = realpath($file);
22-
23-
if ($file === false || strpos($file, __DIR__) !== 0) {
24-
throw new \Exception('Invalid file path');
25-
}
26-
2720
$contents = file_exists($file) ? file_get_contents($file) : '[]';
2821
return json_decode($contents, true);
2922
}
@@ -37,14 +30,7 @@ public function read($file)
3730
*/
3831
public function write($file, $data)
3932
{
40-
// Sanitize the file path
41-
$file = realpath($file);
42-
43-
if ($file === false || strpos($file, __DIR__) !== 0) {
44-
throw new \Exception('Invalid file path');
45-
}
46-
4733
file_put_contents($file, json_encode($data));
4834
}
4935
}
50-
?>
36+
?>

0 commit comments

Comments
 (0)