Skip to content

Commit

Permalink
More changes
Browse files Browse the repository at this point in the history
  • Loading branch information
whikloj committed Jan 17, 2024
1 parent 46ae106 commit 9863871
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
vendor/
clover.xml
mytracedir/
.phpunit.result.cache
4 changes: 2 additions & 2 deletions src/BagUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ private function __construct()
*/
public static function baseInData(string $path): string
{
if (substr($path, 0, 5) !== 'data/') {
if (!str_starts_with($path, 'data/')) {
$path = "data/" . ltrim($path, "/");
}
return $path;
Expand Down Expand Up @@ -120,7 +120,7 @@ public static function getAbsolute(string $path, bool $add_absolute = false): st
{
$path = self::standardizePathSeparators($path);
// Check if path start with a separator (UNIX)
$startWithSeparator = substr($path, 0, 1) === '/';
$startWithSeparator = str_starts_with($path, '/');
// Check if start with drive letter
preg_match('/^[a-z]:/i', $path, $matches);
$startWithLetterDir = $matches[0] ?? false;
Expand Down
2 changes: 1 addition & 1 deletion tests/ManifestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ public function testValidatePathOutsideBagCreate(): void
{
$bag = Bag::create($this->tmpdir);
$this->expectException(BagItException::class);
$this->expectErrorMessage("Path data/../../pictures/another_picture.txt resolves outside the bag.");
$this->expectExceptionMessage("Path data/../../pictures/another_picture.txt resolves outside the bag.");
$bag->addFile(self::TEST_IMAGE['filename'], "data/../../pictures/another_picture.txt");
}
}

0 comments on commit 9863871

Please sign in to comment.