Stash
Stash copied to clipboard
getItem($key) - shouldn't you be trimming whitespace from the key as well as forward slashes?
eg.: trim($key, '/ ')
Line: 107
Because you can't trust the developer to do that every time when the library is expecting a certain type of string.
$key = " some/key";
would be considered an malformed string going through that method, though it's not always easily caught.
I agree with spaces but not forward slashes.
@design1online the reason I said forward slashes because of how Stash deals with forward slashes and automatically grouping arrays. There's really no reason for a cache key to start or end with a forward slash as well.
I've never seen someone write keys like this:
-
user/1/
-
/user/1/
-
/user/1
There's no reason to write cache keys in stash like that at all. If you can give me a use case i'd be glad for you to give me a use case where it's appropriate to write any cache keys like that especially when the next line is an explode:
$key = explode('/', $keyString);
I use keys like that because I create keys based on the classname.
@design1online even when you use them based off class names, there's no reason to have forward slashes starting or ending in the key string.
namespace/subnamespace/classname
Anyways my concern with this issue is because Stash does not do checks for empty strings coming from forward slashes which causes problems when they explode a forward slash string and the key is empty.
//stash/should/break
here