if (lua_gettop (L) >= 2) {
/* url, callback and event_base format */
url = luaL_checkstring (L, 1);
+
if (url == NULL || lua_type (L, 2) != LUA_TFUNCTION) {
msg_err ("http request has bad params");
lua_pushboolean (L, FALSE);
return 1;
}
+
lua_pushvalue (L, 2);
cbref = luaL_ref (L, LUA_REGISTRYINDEX);
+
if (lua_gettop (L) >= 3 && rspamd_lua_check_udata_maybe (L, 3, "rspamd{ev_base}")) {
ev_base = *(struct event_base **)lua_touserdata (L, 3);
}
LUA_FUNCTION_DEF (url, get_query);
LUA_FUNCTION_DEF (url, get_fragment);
LUA_FUNCTION_DEF (url, get_text);
+LUA_FUNCTION_DEF (url, get_raw);
LUA_FUNCTION_DEF (url, get_tld);
LUA_FUNCTION_DEF (url, to_table);
LUA_FUNCTION_DEF (url, is_phished);
LUA_INTERFACE_DEF (url, get_fragment),
LUA_INTERFACE_DEF (url, get_text),
LUA_INTERFACE_DEF (url, get_tld),
+ LUA_INTERFACE_DEF (url, get_raw),
LUA_INTERFACE_DEF (url, to_table),
LUA_INTERFACE_DEF (url, is_phished),
LUA_INTERFACE_DEF (url, is_redirected),
return 1;
}
+/***
+ * @method url:get_raw()
+ * Get full content of the url as it was parsed (e.g. with urldecode)
+ * @return {string} url string
+ */
+static gint
+lua_url_get_raw (lua_State *L)
+{
+ struct rspamd_lua_url *url = lua_check_url (L, 1);
+
+ if (url != NULL) {
+ lua_pushlstring (L, url->url->raw, url->url->rawlen);
+ }
+ else {
+ lua_pushnil (L);
+ }
+
+ return 1;
+}
+
/***
* @method url:is_phished()
* Check whether URL is treated as phished