Module: kamailio
Branch: master
Commit: ed60be162918fc1791ee6425f664eb2f76b9475e
URL:
https://github.com/kamailio/kamailio/commit/ed60be162918fc1791ee6425f664eb2…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2024-04-03T18:52:58+02:00
pv: transformation to escape/unescape cr lf
- {s.escape.crlf}, {s.unescape.crlf}
---
Modified: src/modules/pv/pv_trans.c
Modified: src/modules/pv/pv_trans.h
---
Diff:
https://github.com/kamailio/kamailio/commit/ed60be162918fc1791ee6425f664eb2…
Patch:
https://github.com/kamailio/kamailio/commit/ed60be162918fc1791ee6425f664eb2…
---
diff --git a/src/modules/pv/pv_trans.c b/src/modules/pv/pv_trans.c
index 0cc6f8f2e2c..a3ce0f0ace3 100644
--- a/src/modules/pv/pv_trans.c
+++ b/src/modules/pv/pv_trans.c
@@ -566,6 +566,32 @@ int tr_eval_string(
val->rs.s = _tr_buffer;
val->rs.len = i;
break;
+ case TR_S_ESCAPECRLF:
+ if(!(val->flags & PV_VAL_STR))
+ val->rs.s = int2str(val->ri, &val->rs.len);
+ if(val->rs.len > TR_BUFFER_SIZE / 2 - 1)
+ return -1;
+ st.s = _tr_buffer;
+ st.len = TR_BUFFER_SIZE;
+ if(escape_crlf(&val->rs, &st))
+ return -1;
+ memset(val, 0, sizeof(pv_value_t));
+ val->flags = PV_VAL_STR;
+ val->rs = st;
+ break;
+ case TR_S_UNESCAPECRLF:
+ if(!(val->flags & PV_VAL_STR))
+ val->rs.s = int2str(val->ri, &val->rs.len);
+ if(val->rs.len > TR_BUFFER_SIZE - 1)
+ return -1;
+ st.s = _tr_buffer;
+ st.len = TR_BUFFER_SIZE;
+ if(unescape_crlf(&val->rs, &st))
+ return -1;
+ memset(val, 0, sizeof(pv_value_t));
+ val->flags = PV_VAL_STR;
+ val->rs = st;
+ break;
case TR_S_ESCAPEUSER:
if(!(val->flags & PV_VAL_STR))
val->rs.s = int2str(val->ri, &val->rs.len);
@@ -2768,6 +2794,12 @@ char *tr_parse_string(str *in, trans_t *t)
&& strncasecmp(name.s, "unescape.common", 15) == 0) {
t->subtype = TR_S_UNESCAPECOMMON;
goto done;
+ } else if(name.len == 11 && strncasecmp(name.s, "escape.crlf", 11) ==
0) {
+ t->subtype = TR_S_ESCAPECRLF;
+ goto done;
+ } else if(name.len == 13 && strncasecmp(name.s, "unescape.crlf", 13)
== 0) {
+ t->subtype = TR_S_UNESCAPECRLF;
+ goto done;
} else if(name.len == 11 && strncasecmp(name.s, "escape.user", 11) ==
0) {
t->subtype = TR_S_ESCAPEUSER;
goto done;
diff --git a/src/modules/pv/pv_trans.h b/src/modules/pv/pv_trans.h
index 827f74feb49..662d5a2b578 100644
--- a/src/modules/pv/pv_trans.h
+++ b/src/modules/pv/pv_trans.h
@@ -60,6 +60,8 @@ enum _tr_s_subtype
TR_S_DECODEBASE64,
TR_S_ESCAPECOMMON,
TR_S_UNESCAPECOMMON,
+ TR_S_ESCAPECRLF,
+ TR_S_UNESCAPECRLF,
TR_S_ESCAPEUSER,
TR_S_UNESCAPEUSER,
TR_S_ESCAPEPARAM,