return;
}
- url->visible_part = rspamd_mempool_alloc0(pool, dest->len - href_offset+1);
- gchar *current_processed_char = dest->data + href_offset;
- gchar *current_char_in_struct = url->visible_part;
- gboolean previous_char_was_space = false;
-
- while (current_processed_char < (gchar*) dest->data + dest->len) {
- if (g_ascii_isspace(*current_processed_char)) {
- if (previous_char_was_space) {
- current_processed_char++;
- continue;
- }
- previous_char_was_space = true;
- *current_char_in_struct = ' ';
- } else {
- *current_char_in_struct = *current_processed_char;
- previous_char_was_space = false;
- }
- current_char_in_struct++;
- current_processed_char++;
- }
- *current_char_in_struct = '\0';
- url->visible_partlen = current_char_in_struct - url->visible_part;
+ url->visible_part = rspamd_mempool_alloc (pool, dest->len - href_offset + 1);
+ rspamd_strlcpy (url->visible_part, dest->data + href_offset,
+ dest->len - href_offset + 1);
+ g_strstrip (url->visible_part);
rspamd_html_url_is_phished (pool, url,
dest->data + href_offset,
LUA_TRACE_POINT;
struct rspamd_lua_url *url = lua_check_url (L, 1);
- if (url != NULL) {
- lua_pushlstring (L, url->url->visible_part, url->url->visible_partlen);
+ if (url != NULL && url->url->visible_part) {
+ lua_pushstring (L, url->url->visible_part);
}
else {
lua_pushnil (L);