Module: kamailio
Branch: master
Commit: 75b5325c3b125b8adc551591cd82b67cd3cab167
URL:
https://github.com/kamailio/kamailio/commit/75b5325c3b125b8adc551591cd82b67…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2024-06-25T09:41:56+02:00
pv: new transformation {s.rmhlws}
- remove header line split white spaces (i.e., end of lines and
following white spaces in a multi-line header value)
---
Modified: src/modules/pv/pv_trans.c
Modified: src/modules/pv/pv_trans.h
---
Diff:
https://github.com/kamailio/kamailio/commit/75b5325c3b125b8adc551591cd82b67…
Patch:
https://github.com/kamailio/kamailio/commit/75b5325c3b125b8adc551591cd82b67…
---
diff --git a/src/modules/pv/pv_trans.c b/src/modules/pv/pv_trans.c
index 4418234ddb5..dcf5479a105 100644
--- a/src/modules/pv/pv_trans.c
+++ b/src/modules/pv/pv_trans.c
@@ -274,6 +274,30 @@ int tr_eval_string(
val->rs.s = _tr_buffer;
val->rs.len = j;
break;
+ case TR_S_RMHLWS:
+ 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;
+ j = 0;
+ c = 0;
+ for(i = 0; i < val->rs.len; i++) {
+ if(val->rs.s[i] == '\r' || val->rs.s[i] == '\n') {
+ c = 1;
+ } else if(c != 0 && (val->rs.s[i] == ' ' || val->rs.s[i] ==
'\t')) {
+ c = 2;
+ } else {
+ _tr_buffer[j] = val->rs.s[i];
+ j++;
+ c = 0;
+ }
+ }
+ _tr_buffer[j] = '\0';
+ val->flags = PV_VAL_STR;
+ val->ri = 0;
+ val->rs.s = _tr_buffer;
+ val->rs.len = j;
+ break;
case TR_S_MD5:
if(!(val->flags & PV_VAL_STR))
val->rs.s = int2str(val->ri, &val->rs.len);
@@ -2752,6 +2776,9 @@ char *tr_parse_string(str *in, trans_t *t)
} else if(name.len == 6 && strncasecmp(name.s, "rmhdws", 6) == 0) {
t->subtype = TR_S_RMHDWS;
goto done;
+ } else if(name.len == 6 && strncasecmp(name.s, "rmhlws", 6) == 0) {
+ t->subtype = TR_S_RMHLWS;
+ goto done;
} else if(name.len == 6 && strncasecmp(name.s, "sha256", 6) == 0) {
t->subtype = TR_S_SHA256;
goto done;
diff --git a/src/modules/pv/pv_trans.h b/src/modules/pv/pv_trans.h
index 9eebe1da9d1..6fab2c4233c 100644
--- a/src/modules/pv/pv_trans.h
+++ b/src/modules/pv/pv_trans.h
@@ -97,6 +97,7 @@ enum _tr_s_subtype
TR_S_DECODEBASE64URLT,
TR_S_RMWS,
TR_S_RMHDWS,
+ TR_S_RMHLWS,
TR_S_BEFORE,
TR_S_AFTER,
TR_S_RBEFORE,