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

Trailing equal sign in argument value #91

Open
WojciechLuczkow opened this issue Nov 27, 2020 · 1 comment
Open

Trailing equal sign in argument value #91

WojciechLuczkow opened this issue Nov 27, 2020 · 1 comment

Comments

@WojciechLuczkow
Copy link

Fix for #85 was resolving problem of equal sign in the middle of value.

If one or more = signs are at the end of the value - they are all removed.

Following test case in src/clique_parser.erl will fail:

parse_valid_arg_value_with_trailing_equal_sign_test() ->
    Spec = spec(),
    ArgsAndFlags = ["client-id=anon-Base64v=="],
    {Spec, Args, Flags} = parse({Spec, ArgsAndFlags}),
    ?assertEqual(Args, [{"client-id", "anon-Base64v=="}]),
    ?assertEqual(Flags, []).
@WojciechLuczkow
Copy link
Author

Changing string:token to string:split will fix the issue,

However string:split is available since OTP 20 which is not used in VerneMQ fork

Below I inserted workng replacement for parse_kv_args([Arg | Args], Acc)
It also removes hack for "equal" sign in middle of argument

parse_kv_args([Arg | Args], Acc) ->
    case string:split(Arg, "=") of
        [Key] ->
            {error, {invalid_kv_arg, Key}};
        [Key, []] ->
            {error, {invalid_kv_arg, Key}};
        [Key, Val] ->
            parse_kv_args(Args, [{Key, Val} | Acc])
    end.

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

No branches or pull requests

1 participant