### Description
dialplan ``dp_match()`` fails with a substitution error when subst_exp doesn't match the string. I was expecting to only match the rule to get the attrs no matter what is defined in ``subst_exp/repl_exp``
### Troubleshooting
#### Reproduction
```
=> select * from dialplan where id = 24;
─[ RECORD 1 ]──────────────────────────────────────
id │ 24
dpid │ 101000
pr │ 1
match_op │ 1
match_exp │ ^00([1-9][0-35-9]|[1-35-9][0-9])[0-9]+$
match_len │ 0
subst_exp │ ^([1-9][0-9]{8})$
repl_exp │ +34\1
attrs │ cli=+34654205682;action=0
```
```
route[SET_DST] {
if($var(dpid_team)==0){
xdbg("SET_DST no $$var(dpid_team) - ci='$ci'");
return;
}
xinfo("SET_DST trying to get dialplan from dpid:$var(dpid_team) - ci'$ci'");
if(dp_translate("$(var(dpid_team){s.int})", "$rU/$var(dst)")){
if($rU != $var(dst)){
xinfo("SET_DST change from $$rU:'$rU' to '$var(dst)' - ci='$ci'");
$rU = $var(dst);
}
} else {
xinfo("SET_DST no valid subst_exp for '$rU' trying to match - ci='$ci'");
dp_match("$(var(dpid_team){s.int})", "$rU");
}
if($var(dp_attrs)!=0) {
xdbg("SET_DST $$var(dp_attrs):$var(dp_attrs) "
"action:$(var(dp_attrs){param.value,action}) - ci='$ci'");
$var(action) = $(var(dp_attrs){param.value,action});
if($var(action)=='1'){
xalert("Dialing rule group for '$rU' set to 'deny' - ci='$ci'");
route(ERROR_DEST_DENY);
}
}
return;
}
```
```
INFO: <script>: SET_DST trying to get dialplan from dpid:101000 - ci'57f955434e6ca1e57727367e4abcff1f(a)PBX-2797.xpbx.foehn.co.uk'
ERROR: dialplan [dp_repl.c:439]: rule_translate(): the string 0034654205681 matched the match_exp ^00([1-9][0-35-9]|[1-35-9][0-9])[0-9]+$ but not the subst_exp ^([1-9][0-9]{8})$!
ERROR: dialplan [dp_repl.c:727]: dp_translate_helper(): could not build the output
INFO: <script>: SET_DST no valid subst_exp for '0034654205681' trying to match - ci='57f955434e6ca1e57727367e4abcff1f(a)PBX-2797.xpbx.foehn.co.uk'
ERROR: dialplan [dp_repl.c:439]: rule_translate(): the string 0034654205681 matched the match_exp ^00([1-9][0-35-9]|[1-35-9][0-9])[0-9]+$ but not the subst_exp ^([1-9][0-9]{8})$!
ERROR: dialplan [dp_repl.c:727]: dp_translate_helper(): could not build the output
```
### Additional Information
* **Kamailio Version** - output of `kamailio -v`
```
version: kamailio 5.2.2 (x86_64/linux)
flags: STATS: Off, USE_TCP, USE_TLS, USE_SCTP, TLS_HOOKS, USE_RAW_SOCKS, DISABLE_NAGLE, USE_MCAST, DNS_IP_HACK, SHM_MEM, SHM_MMAP, PKG_MALLOC, Q_MALLOC, F_MALLOC, TLSF_MALLOC, DBG_SR_MEMORY, USE_FUTEX, FAST_LOCK-ADAPTIVE_WAIT, USE_DNS_CACHE, USE_DNS_FAILOVER, USE_NAPTR, USE_DST_BLACKLIST, HAVE_RESOLV_RES
ADAPTIVE_WAIT_LOOPS=1024, MAX_RECV_BUFFER_SIZE 262144 MAX_URI_SIZE 1024, BUF_SIZE 65535, DEFAULT PKG_SIZE 8MB
poll method support: poll, epoll_lt, epoll_et, sigio_rt, select.
id: unknown
compiled with gcc 4.8.4
```
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/issues/1952
```
INFO: <script>: SET_DST trying to get dialplan from dpid:101000 - ci'1cf77cbb5baebdbd0e8635e1116aa713(a)PBX-2797.xpbx.foehn.co.uk'
DEBUG: dialplan [dialplan.c:232]: dp_get_ivalue(): searching 15
DEBUG: dialplan [dialplan.c:240]: dp_get_ivalue(): dpid is 101000 from pv argument
DEBUG: dialplan [dialplan.c:249]: dp_get_svalue(): searching 7
DEBUG: dialplan [dialplan.c:345]: dp_translate_f(): input is 0034654205681
DEBUG: dialplan [dp_repl.c:606]: dp_translate_helper(): regex operator testing over [0034654205681]
DEBUG: dialplan [dp_repl.c:681]: dp_translate_helper(): found a matching rule 0x7f065c2818d0: pr 1, match_exp ^00([1-9][0-35-9]|[1-35-9][0-9])[0-9]+$
DEBUG: dialplan [dp_repl.c:688]: dp_translate_helper(): the rule's attrs are cli=+34654205682;action=0
DEBUG: dialplan [dp_repl.c:699]: dp_translate_helper(): the copied attributes are: cli=+34654205682;action=0
ERROR: dialplan [dp_repl.c:439]: rule_translate(): the string 0034654205681 matched the match_exp ^00([1-9][0-35-9]|[1-35-9][0-9])[0-9]+$ but not the subst_exp ^([1-9][0-9]{8})$!
ERROR: dialplan [dp_repl.c:730]: dp_translate_helper(): could not build the output
DEBUG: dialplan [dialplan.c:350]: dp_translate_f(): could not translate 0034654205681 with dpid 101000
INFO: <script>: SET_DST no valid subst_exp for '0034654205681' trying to match - ci='1cf77cbb5baebdbd0e8635e1116aa713(a)PBX-2797.xpbx.foehn.co.uk'
DEBUG: dialplan [dp_repl.c:606]: dp_translate_helper(): regex operator testing over [0034654205681]
DEBUG: dialplan [dp_repl.c:681]: dp_translate_helper(): found a matching rule 0x7f065c2818d0: pr 1, match_exp ^00([1-9][0-35-9]|[1-35-9][0-9])[0-9]+$
DEBUG: dialplan [dp_repl.c:688]: dp_translate_helper(): the rule's attrs are cli=+34654205682;action=0
DEBUG: dialplan [dp_repl.c:699]: dp_translate_helper(): the copied attributes are: cli=+34654205682;action=0
DEBUG: <script>: SET_DST $var(dp_attrs):cli=+34654205682;action=0 action:0 - ci='1cf77cbb5baebdbd0e8635e1116aa713(a)PBX-2797.xpbx.foehn.co.uk'
```
#### Pre-Submission Checklist
<!-- Go over all points below, and after creating the PR, tick all the checkboxes that apply -->
<!-- All points should be verified, otherwise, read the CONTRIBUTING guidelines from above-->
<!-- If you're unsure about any of these, don't hesitate to ask on sr-dev mailing list -->
- [x] Commit message has the format required by CONTRIBUTING guide
- [x] Commits are split per component (core, individual modules, libs, utils, ...)
- [x] Each component has a single commit (if not, squash them into one commit)
- [x] No commits to README files for modules (changes must be done to docbook files
in `doc/` subfolder, the README file is autogenerated)
#### Type Of Change
- [x] Small bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds new functionality)
- [ ] Breaking change (fix or feature that would change existing functionality)
#### Checklist:
<!-- Go over all points below, and after creating the PR, tick the checkboxes that apply -->
- [x] PR should be backported to stable branches
- [x] Tested changes locally
- [x] Related to issue #1952
#### Description
changing ``dp_replace_helper()`` to pass a NULL value indicating no output is needed ( no need to do subst ) to ``dp_translate_helper()``
You can view, comment on, or merge this pull request online at:
https://github.com/kamailio/kamailio/pull/1953
-- Commit Summary --
* dialplan: don't try to translate on dp_match()
-- File Changes --
M src/modules/dialplan/dialplan.c (14)
M src/modules/dialplan/dp_repl.c (3)
-- Patch Links --
https://github.com/kamailio/kamailio/pull/1953.patchhttps://github.com/kamailio/kamailio/pull/1953.diff
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/pull/1953