slen += INET6_ADDRSTRLEN;
}
+ if (uri->flags & RSPAMD_URL_FLAG_HAS_PORT) {
+ slen += sizeof ("65535") - 1;
+ }
+
/* Allocate new string to build it from IP */
strbuf = rspamd_mempool_alloc (pool, slen + 1);
r += rspamd_snprintf (strbuf + r, slen - r, "%*s",
(gint)(uri->hostshift),
uri->string);
+
uri->hostshift = r;
uri->tldshift = r;
start_offset = strbuf + r;
uri->flags |= RSPAMD_URL_FLAG_NUMERIC;
/* Reconstruct URL */
+ if (uri->flags & RSPAMD_URL_FLAG_HAS_PORT) {
+ p = strbuf + r;
+ start_offset = p + 1;
+ r += rspamd_snprintf (strbuf + r, slen - r, ":%ud",
+ (unsigned int)uri->port);
+ }
if (uri->datalen > 0) {
p = strbuf + r;
start_offset = p + 1;
return 1;
}
+static rspamd_mempool_t *static_lua_url_pool;
+
+RSPAMD_CONSTRUCTOR(rspamd_urls_static_pool_ctor) {
+ static_lua_url_pool = rspamd_mempool_new (rspamd_mempool_suggest_size (),
+ "static_lua_url", 0);
+}
+
+RSPAMD_DESTRUCTOR(rspamd_urls_static_pool_dtor) {
+ rspamd_mempool_delete (static_lua_url_pool);
+}
/***
* @function url.create([mempool,] str, [{flags_table}])
}
else {
own_pool = TRUE;
- pool = rspamd_mempool_new (rspamd_mempool_suggest_size (), "url", 0);
+ pool = static_lua_url_pool;
text = luaL_checklstring (L, 1, &length);
}
if (pool == NULL || text == NULL) {
- if (own_pool && pool) {
- rspamd_mempool_delete (pool);
- }
-
return luaL_error (L, "invalid arguments");
}
else {
}
}
- if (own_pool && pool) {
- rspamd_mempool_delete (pool);
- }
-
return 1;
}