File paths containing ':' messes up loader
Bug #405687 reported by
Valentin Lab
This bug affects 1 person
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
ZConfig |
Fix Released
|
Undecided
|
Unassigned |
Bug Description
method "isPath" of BaseLoader raised an Exception:
..
File "/home/
TypeError: object of type 'NoneType' has no len()
The key factor to trigger the bug is having character ":" in an url that should be checked through 'isPath' method.
You should be able to check this by renaming your zope application path to add a ":" character in it.
I have joined a simple fix.
To post a comment you must log in.
I had a little more time, so there's a new fix that could be ready for integration. I provided two patches, each one resolves the issue with a different solution. The second patch is in the following comment.
Review is needed. The issue is not simple :
>>> assert_ (isPath( "/ab:c" ))
triggered an exception. Which can be pretty annoying if you had a ":" anywhere in your path.
What's happening is that behind the curtains 'isPath' is using 'urllib. splittype( )' which purpose
is to split the "scheme" part from the "resource" part.
It try to find any string at the beginning of the string that does not contain "/" nor ":" and which is separated
by a ":" from the remaining part of the string.
This is a pretty loose check, and raises some concerns (in isPath point of view) about what to return in some cases:
>>> isPath("ab:c")
Should it return "True" it is a relative Path of a directory named "ab:c" OR
Should it return "False" it is NOT a Path as it has a "scheme" identifier which is "ab".
This could lead to the conclusion that isPath purpose and use is not fullfillable this way and a more general refactor could resolve this. Or 'urllib.splittype' might not be the solution and a simple regexp on "://" could be better.
I provided two patch, the first one tackles the problem for absolute paths containing ":" and chooses to return "False" on "ab:c". Next one is in the following comment.