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

\Phalcon\Security\Random:base64Safe() function has problem #12141

Closed
anonymouslab opened this issue Aug 14, 2016 · 2 comments
Closed

\Phalcon\Security\Random:base64Safe() function has problem #12141

anonymouslab opened this issue Aug 14, 2016 · 2 comments
Assignees
Labels
bug A bug report status: medium Medium
Milestone

Comments

@anonymouslab
Copy link

anonymouslab commented Aug 14, 2016

Class Phalcon\Security\Random

    public function base64(int len = null) -> string
    {
        return base64_encode(this->bytes(len));
    }

    public function base64Safe(int len = null, boolean padding = false) -> string
    {
        var s;

        let s = preg_replace("#[^a-z0-9_=-]+#i", "", this->base64(len));

        if !padding {
            return trim(s, "=");
        }

        return s;
    }

please look at this ↓↓↓

let s = preg_replace("#[^a-z0-9_=-]+#i", "", this->base64(len));

this->base64(len) is not include -, _ characters.

so base64Safe() is not include _, - characters.

i think ...

this->base64(len) -> change , + to _, -

after

preg_replace("#[^a-z0-9_=-]+#i", "", .....

thank you for reading.

@Green-Cat
Copy link
Contributor

@sergeyklay

@sergeyklay sergeyklay self-assigned this Aug 14, 2016
@sergeyklay sergeyklay added this to the 3.0.1 milestone Aug 14, 2016
@sergeyklay
Copy link
Contributor

Fixed in the 3.0.x branch.

@niden niden added bug A bug report status: medium Medium and removed Bug - Medium labels Dec 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A bug report status: medium Medium
Projects
None yet
Development

No branches or pull requests

4 participants