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

[mod_command] COND compares strings by length, not by content #2710

Open
ukolovda opened this issue Jan 10, 2025 · 0 comments
Open

[mod_command] COND compares strings by length, not by content #2710

ukolovda opened this issue Jan 10, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@ukolovda
Copy link
Contributor

Describe the bug
cond command returns wrong result for quoted strings:

cond '12' >= '19' ? true : false
give true but should returns false.

To Reproduce
Steps to reproduce the behavior:

append to dialplan:

<action application="set" data="a=${cond('12' >= '19' ? true : false)}" />

FS log:

EXECUTE [depth=0] sofia/internal/00001@freeswitch set(a=true)
2025-01-10 02:18:42.150764 96.80% [DEBUG] mod_dptools.c:1671 SET sofia/internal/00001@freeswitch [a]=[true]

Expected behavior

Quoted strings should compares as a string, as documented:
https://developer.signalwire.com/freeswitch/FreeSWITCH-Explained/Modules/mod_commands_1966741/#cond

Package version or git hash

  • Version [e.g. 1.10.12]

Seems the code is wrong:

a_is_num = (switch_is_number(s_a) && !a_is_quoted);
b_is_num = (switch_is_number(s_b) && !b_is_quoted);
a_f = a_is_num ? atof(s_a) : (float) strlen(s_a);
b_f = b_is_num ? atof(s_b) : (float) strlen(s_b);

...
case O_GE:
is_true = a_f >= b_f;
break;

@ukolovda ukolovda added the bug Something isn't working label Jan 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant