Browse code

core: strutils - trim trailing spaces when comparing hdr names

(cherry picked from commit 6d76b79b81bf448fa1f34753c1d000dc6c1870e0)

Daniel-Constantin Mierla authored on 16/07/2020 07:16:40
Showing 2 changed files
... ...
@@ -28,6 +28,7 @@
28 28
 
29 29
 #include "dprint.h"
30 30
 #include "ut.h"
31
+#include "trim.h"
31 32
 #include "strutils.h"
32 33
 
33 34
 /*! \brief
... ...
@@ -453,16 +454,24 @@ int cmpi_str(str *s1, str *s2)
453 454
 
454 455
 int cmp_hdrname_str(str *s1, str *s2)
455 456
 {
457
+	str n1, n2;
458
+	n1 = *s1;
459
+	n2 = *s2;
460
+	trim_trailing(&n1);
461
+	trim_trailing(&n2);
456 462
 	/* todo: parse hdr name and compare with short/long alternative */
457
-	return cmpi_str(s1, s2);
463
+	return cmpi_str(&n1, &n2);
458 464
 }
459 465
 
460
-int cmp_hdrname_strzn(str *s1, char *s2, size_t n)
466
+int cmp_hdrname_strzn(str *s1, char *s2, size_t len)
461 467
 {
462
-	str s;
463
-	s.s = s2;
464
-	s.len = n;
465
-	return cmpi_str(s1, &s);
468
+	str n1, n2;
469
+	n1 = *s1;
470
+	n2.s = s2;
471
+	n2.len = len;
472
+	trim_trailing(&n1);
473
+	trim_trailing(&n2);
474
+	return cmpi_str(&n1, &n2);
466 475
 }
467 476
 
468 477
 int cmp_str_params(str *s1, str *s2)
... ...
@@ -43,7 +43,7 @@ int cmp_str(str *s1, str *s2);
43 43
 int cmpi_str(str *s1, str *s2);
44 44
 
45 45
 int cmp_hdrname_str(str *s1, str *s2);
46
-int cmp_hdrname_strzn(str *s1, char *s2, size_t n);
46
+int cmp_hdrname_strzn(str *s1, char *s2, size_t len);
47 47
 int cmp_uri_str(str *s1, str *s2);
48 48
 int cmp_uri_light_str(str *s1, str *s2);
49 49
 int cmp_aor_str(str *s1, str *s2);