Skip to content
This repository has been archived by the owner on Jan 8, 2020. It is now read-only.

Update BlockCipher.php #5680

Merged
merged 2 commits into from
Mar 3, 2014
Merged

Update BlockCipher.php #5680

merged 2 commits into from
Mar 3, 2014

Conversation

auterium
Copy link
Contributor

@auterium auterium commented Jan 5, 2014

empty($data) returns false when data is 0 (as integer), 0.0 (as float) & '0' (as string). These values should be allowed to get encrypted

empty($data) returns false when data is 0 (as integer), 0.0 (as float) & '0' (as string). These values should be allowed to get encrypted
@Maks3w
Copy link
Member

Maks3w commented Feb 20, 2014

Please add a test case

@@ -356,7 +356,8 @@ public function getHashAlgorithm()
*/
public function encrypt($data)
{
if (empty($data)) {
// 0 (as integer), 0.0 (as float) & '0' (as string) will return false, though these should be allowed
if (empty($data) && !($data===0 || $data===0.0 || $data==='0')) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be !is_string($data) || $data === ''

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ezimuel Why we don't allow encrypt empty things?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Maks3w your proposal would allow to encrypt an empty array, though I'm not sure that's desirable. On the other hand, my solution still won't allow false values, which I'm not sure if there's a use case where you'll want to encrypt a false.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@auterium !is_string(array()) // TRUE ;-)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My bad. Just had my morning coffee and now my brain is properly working. I'll do the change and test case tonight after work.

@weierophinney
Copy link
Member

@auterium Any time frame on the test cases, so I can set a milestone?

Maks3w added a commit that referenced this pull request Mar 3, 2014
Maks3w added a commit that referenced this pull request Mar 3, 2014
Maks3w added a commit that referenced this pull request Mar 3, 2014
@Maks3w Maks3w merged commit 702d818 into zendframework:master Mar 3, 2014
@auterium
Copy link
Contributor Author

auterium commented Mar 3, 2014

@Maks3w, you got ahead of me, just finished the test case and was about to add it to the request. Shall I do it as a separate pull request?

@Maks3w
Copy link
Member

Maks3w commented Mar 3, 2014

Yep, send it in a new PR

weierophinney added a commit that referenced this pull request Mar 10, 2014
gianarb pushed a commit to zendframework/zend-crypt that referenced this pull request May 15, 2015
gianarb pushed a commit to zendframework/zend-crypt that referenced this pull request May 15, 2015
gianarb pushed a commit to zendframework/zend-crypt that referenced this pull request May 15, 2015
weierophinney added a commit to zendframework/zend-crypt that referenced this pull request May 15, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants