rspamd_url_strerror (int err)
{
switch (err) {
- case URI_ERRNO_OK:
- return "Parsing went well";
- case URI_ERRNO_EMPTY:
- return "The URI string was empty";
- case URI_ERRNO_INVALID_PROTOCOL:
- return "No protocol was found";
- case URI_ERRNO_BAD_FORMAT:
- return "Bad URL format";
- case URI_ERRNO_BAD_ENCODING:
- return "Invalid symbols encoded";
- case URI_ERRNO_INVALID_PORT:
- return "Port number is bad";
- case URI_ERRNO_TLD_MISSING:
- return "TLD part is not detected";
- case URI_ERRNO_HOST_MISSING:
- return "Host part is missing";
+ case URI_ERRNO_OK:
+ return "Parsing went well";
+ case URI_ERRNO_EMPTY:
+ return "The URI string was empty";
+ case URI_ERRNO_INVALID_PROTOCOL:
+ return "No protocol was found";
+ case URI_ERRNO_BAD_FORMAT:
+ return "Bad URL format";
+ case URI_ERRNO_BAD_ENCODING:
+ return "Invalid symbols encoded";
+ case URI_ERRNO_INVALID_PORT:
+ return "Port number is bad";
+ case URI_ERRNO_TLD_MISSING:
+ return "TLD part is not detected";
+ case URI_ERRNO_HOST_MISSING:
+ return "Host part is missing";
+ case URI_ERRNO_TOO_LONG:
+ return "URL is too long";
}
return NULL;
return URI_ERRNO_EMPTY;
}
+ if (len >= G_MAXUINT16 / 2) {
+ return URI_ERRNO_TOO_LONG;
+ }
+
p = uristring;
uri->protocol = PROTOCOL_UNKNOWN;
len = end - uristring;
}
- uri->raw = p;
- uri->rawlen = len;
-
if (flags & RSPAMD_URL_FLAG_MISSINGSLASHES) {
len += 2;
uri->string = rspamd_mempool_alloc (pool, len + 1);
};
struct rspamd_url {
- gchar *raw;
gchar *string;
+ gchar *visible_part;
+ struct rspamd_url *phished_url;
+
+ guint32 flags;
+
guint16 protocol;
+ guint16 protocollen;
guint16 port;
- guint usershift;
- guint hostshift;
- guint datashift;
- guint queryshift;
- guint fragmentshift;
- guint tldshift;
+ guint16 usershift;
+ guint16 hostshift;
+ guint16 datashift;
+ guint16 queryshift;
+ guint16 fragmentshift;
+ guint16 tldshift;
+
- guint16 protocollen;
guint16 userlen;
guint16 hostlen;
guint16 datalen;
guint16 tldlen;
guint16 count;
- guint urllen;
- guint rawlen;
- guint32 flags;
-
- gchar *visible_part;
- struct rspamd_url *phished_url;
+ guint16 urllen;
};
#define rspamd_url_user(u) ((u)->userlen > 0 ? (u)->string + (u)->usershift : NULL)
URI_ERRNO_BAD_ENCODING, /* Bad characters encoding */
URI_ERRNO_BAD_FORMAT,
URI_ERRNO_TLD_MISSING,
- URI_ERRNO_HOST_MISSING
+ URI_ERRNO_HOST_MISSING,
+ URI_ERRNO_TOO_LONG,
};
enum rspamd_url_protocol {