Skip to content

[bug]: Ring group use REPLACE function instead of STRREPLACE #928

@celya44

Description

@celya44

FreePBX Version

FreePBX 17

Issue Description

modules/ringgroups/functions.inc.php
Line 109

if ($ringing == 'Ring' || empty($ringing)) {
       $dialopts = '${DIAL_OPTIONS}' . $ae;
}
elseif ($ringing == "inherit") {
       $dialopts = 'm(${CHANNEL(musicclass)})${REPLACE(DIAL_OPTIONS,r' . $ae . ')}';
}
else {
       $dialopts = 'm(' . $ringing . ')${REPLACE(DIAL_OPTIONS,r' . $ae . ')}';
}

So, the REPLACE could make sense if it's only for "r" character.
(You should note, and I am not sure how to make an other bug report about that, that this replace for "r" character doesn't work well where there is "macro-something" in the dialoption...)

But when $ae is set with one of Q value:

$ae             = match ($grp['elsewhere']) {
     'yes' => 'Q(ANSWERED_ELSEWHERE)',
     'always' => 'c',
     default => 'Q(NO_ANSWER)',
};

you ended up with something like :
Gosub(macro-dial-confirm,s,1(120,m(14-predec)${REPLACE(DIAL_OPTIONS,rQ(ANSWERED_ELSEWHERE))},14201,14300))

So, with REPLACE instead of STRREPLACE, that mean every single character in " rQ(ANSWERED_ELSEWHERE)" are replace with nothing. It's particularly damaging with "(" and ")" that completely butcher argument of some DIAL OPTION.

I had a case, with a call coming from a Queue, going into a ringgroup coming with :
DIAL_OPTIONS=TtrU(macro-auto-blkvm)
and became :
DIAL_OPTIONS=m(44-default)TtUmaco-auto-blkvm

yep, pretty ugly dial options.

Operating Environment

framework : 17.0.21.2
ringgroups : 17.0.2.8
Asterisk 22.5.2

Relevant log output

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtriageTriage

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions