Skip to content

State with =, & characters is incorrectly parsed from url fragment #913

@selaux

Description

@selaux

Whenever the state in the login callback url fragment includes an equal sign, it looses anything after the equal sign. The reason for that it that decodeUriComponent is called on the whole url fragment before parsing it, leading to encoded characters in state to make new query params instead of still belonging to hash.

  • Code snippet or sample project that reproduces the bug
const lock = new Lock('clientId', 'domain', {
    auth: {
        responseType: 'token',
        params: {
            // example 1
            state: '/some/path/to/redirect?q=firstparam&p=secondparam',
            // example 2
            state: 'asd&q=firstparam&p=secondparam'
        }
    }
});

lock.on('authenticated', function (result) {
    // will log /some/path/to/redirect?q= for example 1
    // will log asd for example 2
    console.log(result.state);
});
  • Lock version: 10.12.3
  • Browser & OS: Any

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThis points to a verified bug in the code

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions