Discussion:
[sr-dev] git:5.5:efb164b7: pv: support escaped chars for s.select separator
Daniel-Constantin Mierla
2021-05-26 06:16:02 UTC
Permalink
Content preview: Module: kamailio Branch: 5.5 Commit: efb164b78ac97d83c12846a35c60fa47fd2d984c
URL: https://github.com/kamailio/kamailio/commit/efb164b78ac97d83c12846a35c60fa47fd2d984c
Author: Daniel-Constantin Mierla <***@gmail.com> Committer: Daniel-Constantin
Mierla <***@gmail.com> Date: 2021-05-26T08:13:49+02:00

Content analysis details: (-2.4 points, 5.5 required)

pts rule name description
---- ---------------------- --------------------------------------------------
-1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP
-1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1%
[score: 0.0000]
0.2 HEADER_FROM_DIFFERENT_DOMAINS From and EnvelopeFrom 2nd level
mail domains are different
1.0 FORGED_GMAIL_RCVD 'From' gmail.com does not match 'Received'
headers
0.0 DKIM_ADSP_CUSTOM_MED No valid author signature, adsp_override is
CUSTOM_MED
0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail
provider (miconda[at]gmail.com)
0.2 FREEMAIL_FORGED_FROMDOMAIN 2nd level domains in From and
EnvelopeFrom freemail headers are
different
-1.0 MAILING_LIST_MULTI Multiple indicators imply a widely-seen list
manager

Module: kamailio
Branch: 5.5
Commit: efb164b78ac97d83c12846a35c60fa47fd2d984c
URL: https://github.com/kamailio/kamailio/commit/efb164b78ac97d83c12846a35c60fa47fd2d984c

Author: Daniel-Constantin Mierla <***@gmail.com>
Committer: Daniel-Constantin Mierla <***@gmail.com>
Date: 2021-05-26T08:13:49+02:00

pv: support escaped chars for s.select separator

- \\, \n, \r, \t

(cherry picked from commit f2973cf0dce0de5c002ac8ee61ac7e829823ed0e)

---

Modified: src/modules/pv/pv_trans.c

---

Diff: https://github.com/kamailio/kamailio/commit/efb164b78ac97d83c12846a35c60fa47fd2d984c.diff
Patch: https://github.com/kamailio/kamailio/commit/efb164b78ac97d83c12846a35c60fa47fd2d984c.patch

---

diff --git a/src/modules/pv/pv_trans.c b/src/modules/pv/pv_trans.c
index c9e7438b83..2f10f67080 100644
--- a/src/modules/pv/pv_trans.c
+++ b/src/modules/pv/pv_trans.c
@@ -191,6 +191,7 @@ int tr_eval_string(struct sip_msg *msg, tr_param_t *tp, int subtype,
{
int i, j, max;
char *p, *s;
+ char c;
str st, st2;
pv_value_t v, w;
time_t t;
@@ -731,6 +732,28 @@ int tr_eval_string(struct sip_msg *msg, tr_param_t *tp, int subtype,
}
i = v.ri;
}
+ if(tp->next->v.s.len>1) {
+ switch(tp->next->v.s.s[1]) {
+ case '\\':
+ c = '\\';
+ break;
+ case 'n':
+ c = '\n';
+ break;
+ case 'r':
+ c = '\r';
+ break;
+ case 't':
+ c = '\t';
+ break;
+ default:
+ LM_ERR("invalid select escape char (cfg line: %d)\n",
+ get_cfg_crt_line());
+ return -1;
+ }
+ } else {
+ c = tp->next->v.s.s[0];
+ }
val->flags = PV_VAL_STR;
val->ri = 0;
if(i<0)
@@ -741,7 +764,7 @@ int tr_eval_string(struct sip_msg *msg, tr_param_t *tp, int subtype,
i--;
while(p>=val->rs.s)
{
- if(*p==tp->next->v.s.s[0])
+ if(*p==c)
{
if(i==0)
break;
@@ -762,7 +785,7 @@ int tr_eval_string(struct sip_msg *msg, tr_param_t *tp, int subtype,
p = s;
while(p<val->rs.s+val->rs.len)
{
- if(*p==tp->next->v.s.s[0])
+ if(*p==c)
{
if(i==0)
break;
@@ -2728,6 +2751,15 @@ char* tr_parse_string(str* in, trans_t *t)
tp->type = TR_PARAM_STRING;
tp->v.s.s = p;
tp->v.s.len = 1;
+ if(*p=='\\') {
+ if(*p=='\\' || *p=='n' || *p=='r' || *p=='t') {
+ p++;
+ tp->v.s.len = 2;
+ } else {
+ LM_ERR("unexpected escape char: %c\n", *p);
+ goto error;
+ }
+ }
t->params->next = tp;
tp = 0;
p++;

Loading...