Module: kamailio
Branch: master
Commit: 6cdd56bb85e1a10ebbb29c2633fb47bf7b56585e
URL:
https://github.com/kamailio/kamailio/commit/6cdd56bb85e1a10ebbb29c2633fb47b…
Author: anmartan <a.martin(a)zaleos.net>
Committer: Henning Westerholt <hw(a)gilawa.com>
Date: 2024-07-11T10:23:21+02:00
core: Improved URN parsing according to RFC8141
- Improved URN parsing to allow consuming URNs that contain 3 or more colons. Previosly
URI parser treated some of the colons as separator between host and port causing the URN
parsing to fail.
---
Modified: src/core/parser/parse_uri.c
---
Diff:
https://github.com/kamailio/kamailio/commit/6cdd56bb85e1a10ebbb29c2633fb47b…
Patch:
https://github.com/kamailio/kamailio/commit/6cdd56bb85e1a10ebbb29c2633fb47b…
---
diff --git a/src/core/parser/parse_uri.c b/src/core/parser/parse_uri.c
index 9ccb62ee51e..4150c1598d6 100644
--- a/src/core/parser/parse_uri.c
+++ b/src/core/parser/parse_uri.c
@@ -237,28 +237,30 @@ int parse_uri(char *buf, int len, struct sip_uri *uri)
} else \
goto error_bad_char
-#define check_host_end \
- case ':': \
- /* found the host */ \
- uri->host.s = s; \
- uri->host.len = p - s; \
- state = URI_PORT; \
- s = p + 1; \
- break; \
- case ';': \
- uri->host.s = s; \
- uri->host.len = p - s; \
- state = URI_PARAM; \
- s = p + 1; \
- break; \
- case '?': \
- uri->host.s = s; \
- uri->host.len = p - s; \
- state = URI_HEADERS; \
- s = p + 1; \
- break; \
- case '&': \
- case '@': \
+#define check_host_end \
+ case ':': \
+ /* found the host */ \
+ if(scheme != URN_SCH) { \
+ uri->host.s = s; \
+ uri->host.len = p - s; \
+ state = URI_PORT; \
+ s = p + 1; \
+ } \
+ break; \
+ case ';': \
+ uri->host.s = s; \
+ uri->host.len = p - s; \
+ state = URI_PARAM; \
+ s = p + 1; \
+ break; \
+ case '?': \
+ uri->host.s = s; \
+ uri->host.len = p - s; \
+ state = URI_HEADERS; \
+ s = p + 1; \
+ break; \
+ case '&': \
+ case '@': \
goto error_bad_char
@@ -493,7 +495,7 @@ int parse_uri(char *buf, int len, struct sip_uri *uri)
case '@': /* error no user part, or
* be forgiving and accept it ? */
default:
- state = URI_USER;
+ state = (scheme == URN_SCH) ? URI_HOST : URI_USER;
}
break;
case URI_USER: