"%3E%3F%40%5B%5C%5D%5E_%60%7B%7C%7D~resource",
"xmpp:ji%C5%99i@%C4%8Dechy.example/v%20Praze",
/* from RFC 5456 */
-#if 0 // these don't comply with RFC 3986
"iax:example.com/alice",
"iax:example.com:4569/alice",
"iax:example.com:4570/alice?friends",
"iax:alice@AtLaNtA.com:4569/ALicE",
"iax:ALICE@atlanta.com/alice",
"iax:alice@atlanta.com/alice",
-#endif
/* from RFC 5724 */
"sms:+15105550101",
"sms:+15105550101,+15105550102",
test_end();
}
+static void test_uri_iax(void)
+{
+ test_begin("uri iax");
+ const char *uri = "iax:[2001:db8::1]:4569/alice?friend";
+ struct uri_parser parser;
+ uri_parser_init(&parser, pool_datastack_create(), uri);
+
+ const char *scheme;
+ struct uri_authority auth;
+ int relative;
+ const char *const *path;
+ const char *query;
+ int ret;
+ ret = uri_parse_scheme(&parser, &scheme);
+ test_assert(ret > 0);
+ test_assert_strcmp(scheme, "iax");
+ ret = uri_parse_host_authority(&parser, &auth);
+ test_assert(ret > 0);
+ test_assert_strcmp(auth.host.name, "[2001:db8::1]");
+ test_assert_ucmp(auth.port, ==, 4569);
+ ret = uri_parse_path(&parser, &relative, &path);
+ test_assert(ret > 0);
+ test_assert(relative == 0);
+ test_assert_strcmp(path[0], "alice");
+ test_assert(path[1] == NULL);
+ ret = uri_parse_query(&parser, &query);
+ test_assert(ret > 0);
+ test_assert_strcmp(query, "friend");
+ test_end();
+}
+
+
void test_uri(void)
{
test_uri_valid();
test_uri_rfc();
test_uri_escape();
test_uri_aaa();
+ test_uri_iax();
}
enum uri_parse_flags flags)
{
int relative, aret, ret = 0;
+ bool allow_missing_slashslash = FALSE;
/* URI = scheme ":" hier-part [ "?" query ] [ "#" fragment ]
if (strcmp(scheme, "aaa") == 0 ||
(flags & URI_PARSE_SEMICOLON_PARAMS) != 0)
parser->semicolon_params = TRUE;
+ if (strcmp(scheme, "iax") == 0 ||
+ (flags & URI_PARSE_ALLOW_MISSING_SLASHSLASH) != 0)
+ allow_missing_slashslash = TRUE;
}
/* "//" authority */
aret = uri_parse_slashslash_authority(parser, NULL);
if (aret < 0)
return -1;
+ else if (aret == 0 && allow_missing_slashslash) {
+ if ((aret = uri_parse_authority(parser, NULL)) < 0)
+ return -1;
+ }
/* path-absolute / path-rootless / path-empty */
if (aret == 0) {
URI_PARSE_ALLOW_FRAGMENT_PART = BIT(1),
/* Allow ';param' after host - violates RFC3986 */
URI_PARSE_SEMICOLON_PARAMS = BIT(2),
+ /* Allow scheme:host - violates RFC3986 */
+ URI_PARSE_ALLOW_MISSING_SLASHSLASH = BIT(3),
};
struct uri_host {