rspamd_urlThis module provides routines to handle URL’s and extract URL’s from the text.
Objects of this class are returned, for example, by task:get_urls() or task:get_emails().
You can also create rspamd_url from any text.
local url = require "rspamd_url"
local pool = mpool.create()
local res = url.create(pool, 'Look at: http://user@test.example.com/test?query")
local t = res:to_table()
-- Content of t:
-- url = ['http://test.example.com/test?query']
-- host = ['test.example.com']
-- user = ['user']
-- path = ['test']
-- tld = ['example.com']
pool:destroy() -- res is destroyed here, so you should not use it afterwards
local mistake = res:to_table() -- INVALID! as pool is destroyedFunctions:
Methods:
The module rspamd_url defines the following functions.
url.create([mempool,] str)Parameters:
memory {rspamd_mempool}: pool for URL, e.g. task:get_mempool()text {string}: that contains URL (can also contain other stuff)Returns:
{url}: new url object that exists as long as the corresponding mempool existsBack to module description.
url.create(tld_file)Initialize url library if not initialized yet by Rspamd
Parameters:
tld_file {string}: for url libraryReturns:
Back to module description.
The module rspamd_url defines the following methods.
url:get_length()Get length of the url
Parameters:
No parameters
Returns:
{number}: length of url in bytesBack to module description.
url:get_host()Get domain part of the url
Parameters:
No parameters
Returns:
{string}: domain part of URLBack to module description.
url:get_port()Get port of the url
Parameters:
No parameters
Returns:
{number}: url portBack to module description.
url:get_user()Get user part of the url (e.g. username in email)
Parameters:
No parameters
Returns:
{string}: user part of URLBack to module description.
url:get_path()Get path of the url
Parameters:
No parameters
Returns:
{string}: path part of URLBack to module description.
url:get_query()Get query of the url
Parameters:
No parameters
Returns:
{string}: query part of URLBack to module description.
url:get_fragment()Get fragment of the url
Parameters:
No parameters
Returns:
{string}: fragment part of URLBack to module description.
url:get_text()Get full content of the url
Parameters:
No parameters
Returns:
{string}: url stringBack to module description.
url:is_phished()Check whether URL is treated as phished
Parameters:
No parameters
Returns:
{boolean}: true if URL is phishedBack to module description.
url:is_redirected()Check whether URL was redirected
Parameters:
No parameters
Returns:
{boolean}: true if URL is redirectedBack to module description.
url:is_obscured()Check whether URL is treated as obscured or obfusicated (e.g. numbers in IP address or other hacks)
Parameters:
No parameters
Returns:
{boolean}: true if URL is obscuredBack to module description.
url:is_html_displayed()Check whether URL is just displayed in HTML (e.g. NOT a real href)
Parameters:
No parameters
Returns:
{boolean}: true if URL is displayed onlyBack to module description.
url:is_subject()Check whether URL is found in subject
Parameters:
No parameters
Returns:
{boolean}: true if URL is found in subjectBack to module description.
url:get_tag(tag)Returns list of string for a specific tagname for an url
Parameters:
No parameters
Returns:
{table/strings}: list of tags for an urlBack to module description.
url:get_tags()Returns list of string tags for an url
Parameters:
No parameters
Returns:
{table/strings}: list of tags for an urlBack to module description.
url:add_tag(tag, mempool)Adds a new tag for url
Parameters:
tag {string}: new tag to addmempool {mempool}: memory pool (e.g. task:get_pool())Returns:
No return
Back to module description.
url:get_phished()Get another URL that pretends to be this URL (e.g. used in phishing)
Parameters:
No parameters
Returns:
{url}: phished URLBack to module description.
url:get_tld()Get effective second level domain part (eSLD) of the url host
Parameters:
No parameters
Returns:
{string}: effective second level domain part (eSLD) of the url hostBack to module description.
url:get_count()Return number of occurrencies for this particular URL
Parameters:
No parameters
Returns:
{number}: number of occurrenciesBack to module description.
url:to_table()Return url as a table with the following fields:
url: full contenthost: hostname partuser: user partpath: path parttld: top level domainprotocol: url protocolParameters:
No parameters
Returns:
{table}: URL as a tableBack to module description.
Back to top.