Skip to content

Commit

Permalink
core: strutils - trim trailing spaces when comparing hdr names
Browse files Browse the repository at this point in the history
(cherry picked from commit 6d76b79)
(cherry picked from commit d0f7c70)
(cherry picked from commit 340deab)
  • Loading branch information
miconda committed Jul 16, 2020
1 parent b4789a0 commit 27d5945
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
21 changes: 15 additions & 6 deletions src/core/strutils.c
Expand Up @@ -28,6 +28,7 @@

#include "dprint.h"
#include "ut.h"
#include "trim.h"
#include "strutils.h"

/*! \brief
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/core/strutils.h
Expand Up @@ -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);

Expand Down

0 comments on commit 27d5945

Please sign in to comment.