[FS Drivers] Fix invalid characters #221

Closed
wants to merge 3 commits into
from

Conversation

Projects
None yet
6 participants
Owner

FabioBatSilva commented Nov 17, 2012

This patch is proposal to fix #180
by replace invalid characters and hashing the filename as sub directories to create a unique path.

Hello,

thank you for positing this Pull Request. I have automatically opened an issue on our Jira Bug Tracker for you with the details of this Pull-Request. See the Link:

http://doctrine-project.org/jira/browse/DCOM-141

@Ocramius Ocramius commented on the diff Nov 17, 2012

tests/Doctrine/Tests/Common/Cache/FileCacheTest.php
+ 'Doctrine\Common\Cache\FileCache',
+ array('doFetch', 'doContains', 'doSave'),
+ array(), '', false
+ );
+ }
+
+ public function getProviderFileName()
+ {
+ return array(
+ //The characters :\/<>"*?| are not valid in Windows filenames.
+ array('key:1', 'key1'),
+ array('key\2', 'key2'),
+ array('key/3', 'key3'),
+ array('key<4', 'key4'),
+ array('key>5', 'key5'),
+ array('key"6', 'key6'),
@Ocramius

Ocramius Nov 17, 2012

Owner

What happens with key"6 and key>6? (that's why I suggested prepending the hash)

@FabioBatSilva

FabioBatSilva Nov 17, 2012

Owner

@Ocramius even so there are no collisions. the path will be different.

I added another test, please take a look..

key:6 -> /495d80004e0d8b98/00de3d8352b57684/cc9c356c2bed619b/935e794b562513ed/key6
key\6 -> /27689c7696334f66/723368a8c165717d/5f4bac1e59614291/0290d9477df585df/key6
key/6 -> /966c4c8ee8f76a35/3d6d11836fc89705/ccb9ca43dd9688fd/6be83d9d348c884e/key6
key"6 -> /0e69680bd4076662/6853cbad327d0545/7bf2f621876764e6/9361a8ca65dd2d8b/key6
key*6 -> /da68d27386a73d97/c8839c300f66b0dd/3fdb7e03e13ce6cc/d1a4c2c75344aaa6/key6

...

Anyway, I don't see any problem with prepend the hash..

@Ocramius

Ocramius Nov 17, 2012

Owner

Awesome :)

@stof

stof Nov 17, 2012

Member

but this would create lots of directories with a single file in them, no ?

@FabioBatSilva

FabioBatSilva Nov 18, 2012

Owner

@stof that's the goal. It already creates 4 sub directories.
Lots of files in the same directory might be a problem depending on the OS

I just changed the hash algorithm to avoid collision.
.

Owner

beberlei commented Jan 10, 2013

Merged into Doctrine Cache

beberlei closed this Jan 10, 2013

Member

lsmith77 commented Apr 8, 2013

do i understand it properly that this fix will not be applied to doctrine common 2.3?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment