Skip to content

Exlude dir does not work with relative (../..) parent dir #13

@milo

Description

@milo
  • bug report? yes
  • feature request? no
  • version: 3.0.2

Description

In Nette application bootstrap, I call:

$configurator->createRobotLoader()
	->addDirectory(__DIR__)
	->addDirectory(__DIR__ . '/../lib')
	->excludeDirectory(__DIR__ . '/../lib/tcpdf')
	->register();

but exclusion does not work because on line

$path = str_replace('\\', '/', $dir->getPathname());

leads to

$disallow === [
    "D:/Web/project/lib/tcpdf" => true,
];

$path === "D:/Web/project/app/../lib/tcpdf";

I have two solutions in my mind:

  1. Convert path to realpath in addDirectory() and:
    a) ignore missing paths
    b) throw an exception on missing paths (BC break probability)
  2. Modify mentioned line from $dir->getPathname() to $dir->getRealPath().

Which fix would you prefer? Another one?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions