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

[1.x] Fix password rule #211

Merged
merged 2 commits into from
Jan 28, 2021
Merged

[1.x] Fix password rule #211

merged 2 commits into from
Jan 28, 2021

Conversation

driesvints
Copy link
Member

This fixes a bug when a non-string value is password as input for a password. For example, as an array through an API request from a third party.

#209

@@ -51,6 +51,8 @@ class Password implements Rule
*/
public function passes($attribute, $value)
{
$value = is_array($value) ? '' : (string) $value;

Choose a reason for hiding this comment

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

Would it make more sense to flip this to an is_scalar($value) ? (string) $value : '' to also capture any possible scenario where the input is an object, although that wouldn't really happen with validating requests but could happen if someone were to run the Validator manually.

The current approach would also convert any class that has __toString implemented, not sure if you intended it like that?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good suggestion, done 👍

@taylorotwell taylorotwell merged commit e309222 into 1.x Jan 28, 2021
@taylorotwell taylorotwell deleted the fix-password-rule branch January 28, 2021 14:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants