From 27d5945103de6cc6c71cc1ebb2e3579577268e5c Mon Sep 17 00:00:00 2001 From: Daniel-Constantin Mierla Date: Thu, 16 Jul 2020 09:16:40 +0200 Subject: [PATCH] core: strutils - trim trailing spaces when comparing hdr names (cherry picked from commit 6d76b79b81bf448fa1f34753c1d000dc6c1870e0) (cherry picked from commit d0f7c7056b32351cac0b20ce24b074d9be8459a2) (cherry picked from commit 340deabc375272dc3f0a921786890dab8ee778b3) --- src/core/strutils.c | 21 +++++++++++++++------ src/core/strutils.h | 2 +- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/core/strutils.c b/src/core/strutils.c index b06fa44175b..f7f6571a6fe 100644 --- a/src/core/strutils.c +++ b/src/core/strutils.c @@ -28,6 +28,7 @@ #include "dprint.h" #include "ut.h" +#include "trim.h" #include "strutils.h" /*! \brief @@ -453,16 +454,24 @@ int cmpi_str(str *s1, str *s2) int cmp_hdrname_str(str *s1, str *s2) { + str n1, n2; + n1 = *s1; + n2 = *s2; + trim_trailing(&n1); + trim_trailing(&n2); /* todo: parse hdr name and compare with short/long alternative */ - return cmpi_str(s1, s2); + return cmpi_str(&n1, &n2); } -int cmp_hdrname_strzn(str *s1, char *s2, size_t n) +int cmp_hdrname_strzn(str *s1, char *s2, size_t len) { - str s; - s.s = s2; - s.len = n; - return cmpi_str(s1, &s); + str n1, n2; + n1 = *s1; + n2.s = s2; + n2.len = len; + trim_trailing(&n1); + trim_trailing(&n2); + return cmpi_str(&n1, &n2); } int cmp_str_params(str *s1, str *s2) diff --git a/src/core/strutils.h b/src/core/strutils.h index 37152dd18d1..a1f989436c7 100644 --- a/src/core/strutils.h +++ b/src/core/strutils.h @@ -43,7 +43,7 @@ int cmp_str(str *s1, str *s2); int cmpi_str(str *s1, str *s2); int cmp_hdrname_str(str *s1, str *s2); -int cmp_hdrname_strzn(str *s1, char *s2, size_t n); +int cmp_hdrname_strzn(str *s1, char *s2, size_t len); int cmp_uri_str(str *s1, str *s2); int cmp_aor_str(str *s1, str *s2);