Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
milo opened this issue May 2, 2018 · 2 comments
Closed

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

milo opened this issue May 2, 2018 · 2 comments

Comments

@milo
Copy link
Member

@milo milo commented May 2, 2018

  • 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?

@milo milo changed the title Exlude dir does not work with relative parent dir Exlude dir does not work with relative (/../..) parent dir May 2, 2018
@milo milo changed the title Exlude dir does not work with relative (/../..) parent dir Exlude dir does not work with relative (../..) parent dir May 2, 2018
@dg

This comment has been minimized.

Copy link
Member

@dg dg commented May 2, 2018

getRealPath() seems best, because is called only when refreshing cache, right?

@milo

This comment has been minimized.

Copy link
Member Author

@milo milo commented May 2, 2018

I think so, good point. I'll open PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.