Module: kamailio Branch: 5.8 Commit: 7c3b8823ce7ba1395e5b6c59c7e0c2aa0bbeb900 URL: https://github.com/kamailio/kamailio/commit/7c3b8823ce7ba1395e5b6c59c7e0c2aa...
Author: anmartan a.martin@zaleos.net Committer: Xenofon Karamanos 22965395+xkaraman@users.noreply.github.com Date: 2024-11-06T13:27:23Z
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.
(cherry picked from commit 6cdd56bb85e1a10ebbb29c2633fb47bf7b56585e)
---
Modified: src/core/parser/parse_uri.c
---
Diff: https://github.com/kamailio/kamailio/commit/7c3b8823ce7ba1395e5b6c59c7e0c2aa... Patch: https://github.com/kamailio/kamailio/commit/7c3b8823ce7ba1395e5b6c59c7e0c2aa...
---
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: