mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-22 16:20:52 +01:00
* src/mod_muc/mod_muc_log.erl: Spam prevention: The default behaviour
is now to use the nofollow rel attributes for links that are submitted by users (EJAB-185). * doc/guide.tex: Likewise. SVN Revision: 728
This commit is contained in:
parent
909cfd7b21
commit
5882e29fb6
@ -1,8 +1,13 @@
|
||||
2007-02-19 Mickael Remond <mickael.remond@process-one.net>
|
||||
|
||||
* src/mod_muc/mod_muc_log.erl: Spam prevention: The default behaviour
|
||||
is now to use the nofollow rel attributes for links that are submitted
|
||||
by users (EJAB-185).
|
||||
* doc/guide.tex: Likewise.
|
||||
|
||||
* src/mod_muc/mod_muc_room.erl: API improvement: Implementation of an
|
||||
event to destroy MUC room from an external application (Thanks to
|
||||
Massimiliano Mirra) (EJAB-184).
|
||||
Massimiliano Mirra) (EJAB-184).
|
||||
|
||||
2007-02-18 Alexey Shchepin <alexey@sevcom.net>
|
||||
|
||||
|
@ -2023,6 +2023,11 @@ Options:
|
||||
are \term{local} and \term{universal}. With the first value, the local time,
|
||||
as reported to Erlang by the operating system, will be used. With the latter,
|
||||
GMT/UTC time will be used. The default value is \term{local}.
|
||||
\titem{spam\_prevention}\ind{options!spam\_prevention}
|
||||
To prevent spam, the \term{spam_prevention} option adds a special attribute
|
||||
to links that prevent their indexation by search engines. The default value
|
||||
is \term{true}, which mean that nofollow attributes will be added to user
|
||||
submitted links.
|
||||
\titem{top\_link}\ind{options!top\_link}
|
||||
With this option you can customize the link on the top right corner of each
|
||||
log file. The syntax of this option is \term{\{"URL", "Text"\}}. The default
|
||||
@ -2049,6 +2054,7 @@ Examples:
|
||||
{dirtype, plain},
|
||||
{outdir, "/var/www/muclogs"},
|
||||
{timezone, universal},
|
||||
{spam_prevention, true},
|
||||
{top_link, {"http://www.jabber.ru", "Jabber.ru"}}
|
||||
]},
|
||||
...
|
||||
|
@ -38,6 +38,7 @@
|
||||
access,
|
||||
lang,
|
||||
timezone,
|
||||
spam_prevention,
|
||||
top_link}).
|
||||
|
||||
%%====================================================================
|
||||
@ -98,6 +99,7 @@ init([Host, Opts]) ->
|
||||
AccessLog = gen_mod:get_opt(access_log, Opts, muc_admin),
|
||||
Timezone = gen_mod:get_opt(timezone, Opts, local),
|
||||
Top_link = gen_mod:get_opt(top_link, Opts, {"/", "Home"}),
|
||||
NoFollow = gen_mod:get_opt(spam_prevention, Opts, true),
|
||||
Lang = case ejabberd_config:get_local_option({language, Host}) of
|
||||
undefined ->
|
||||
"";
|
||||
@ -111,6 +113,7 @@ init([Host, Opts]) ->
|
||||
access = AccessLog,
|
||||
lang = Lang,
|
||||
timezone = Timezone,
|
||||
spam_prevention = NoFollow,
|
||||
top_link = Top_link}}.
|
||||
|
||||
%%--------------------------------------------------------------------
|
||||
@ -261,6 +264,7 @@ add_message_to_log(Nick1, Message, RoomJID, Opts, State) ->
|
||||
css_file = CSSFile,
|
||||
lang = Lang,
|
||||
timezone = Timezone,
|
||||
spam_prevention = NoFollow,
|
||||
top_link = TopLink} = State,
|
||||
Room = get_room_info(RoomJID, Opts),
|
||||
|
||||
@ -319,7 +323,7 @@ add_message_to_log(Nick1, Message, RoomJID, Opts, State) ->
|
||||
[Nick, ?T("leaves the room")]);
|
||||
{leave, Reason} ->
|
||||
io_lib:format("<font class=\"ml\">~s ~s: ~s</font><br/>",
|
||||
[Nick, ?T("leaves the room"), htmlize(Reason)]);
|
||||
[Nick, ?T("leaves the room"), htmlize(Reason,NoFollow)]);
|
||||
{kickban, "307", ""} ->
|
||||
io_lib:format("<font class=\"mk\">~s ~s</font><br/>",
|
||||
[Nick, ?T("has been kicked")]);
|
||||
@ -337,7 +341,7 @@ add_message_to_log(Nick1, Message, RoomJID, Opts, State) ->
|
||||
[OldNick, ?T("is now known as"), Nick]);
|
||||
{subject, T} ->
|
||||
io_lib:format("<font class=\"msc\">~s~s~s</font><br/>",
|
||||
[Nick, ?T(" has set the subject to: "), htmlize(T)]);
|
||||
[Nick, ?T(" has set the subject to: "), htmlize(T,NoFollow)]);
|
||||
{body, T} ->
|
||||
case regexp:first_match(T, "^/me\s") of
|
||||
{match, _, _} ->
|
||||
@ -345,7 +349,7 @@ add_message_to_log(Nick1, Message, RoomJID, Opts, State) ->
|
||||
[Nick, string:substr(htmlize(T), 5)]);
|
||||
nomatch ->
|
||||
io_lib:format("<font class=\"mn\"><~s></font> ~s<br/>",
|
||||
[Nick, htmlize(T)])
|
||||
[Nick, htmlize(T,NoFollow)])
|
||||
end
|
||||
end,
|
||||
{Hour, Minute, Second} = Time,
|
||||
@ -640,11 +644,19 @@ put_room_config(F, RoomConfig, Lang) ->
|
||||
fw(F, "<div class=\"rcos\" id=\"a~p\" style=\"display: none;\" ><br/>~s</div>", [Now2, RoomConfig]),
|
||||
fw(F, "</div>").
|
||||
|
||||
%% htmlize
|
||||
%% The default behaviour is to ignore the nofollow spam prevention on links
|
||||
%% (NoFollow=false)
|
||||
htmlize(S1) ->
|
||||
htmlize(S1, false).
|
||||
|
||||
%% The NoFollow parameter tell if the spam prevention should be applied to the link found
|
||||
%% true means 'apply nofollow on links'.
|
||||
htmlize(S1, NoFollow) ->
|
||||
S2_list = string:tokens(S1, "\n"),
|
||||
lists:foldl(
|
||||
fun(Si, Res) ->
|
||||
Si2 = htmlize2(Si),
|
||||
Si2 = htmlize2(Si, NoFollow),
|
||||
case Res of
|
||||
"" -> Si2;
|
||||
_ -> Res ++ "<br/>" ++ Si2
|
||||
@ -653,14 +665,21 @@ htmlize(S1) ->
|
||||
"",
|
||||
S2_list).
|
||||
|
||||
htmlize2(S1) ->
|
||||
htmlize2(S1, NoFollow) ->
|
||||
S2 = element(2, regexp:gsub(S1, "\\&", "\\&")),
|
||||
S3 = element(2, regexp:gsub(S2, "<", "\\<")),
|
||||
S4 = element(2, regexp:gsub(S3, ">", "\\>")),
|
||||
S5 = element(2, regexp:gsub(S4, "(http|ftp)://.[^ ]*", "<a href=\"&\">&</a>")),
|
||||
S5 = element(2, regexp:gsub(S4, "(http|ftp)://.[^ ]*", link_regexp(NoFollow))),
|
||||
%% Remove 'right-to-left override' unicode character 0x202e
|
||||
element(2, regexp:gsub(S5, [226,128,174], "[RLO]")).
|
||||
|
||||
%% Regexp link
|
||||
%% Add the nofollow rel attribute when required
|
||||
link_regexp(false) ->
|
||||
"<a href=\"&\">&</a>";
|
||||
link_regexp(true) ->
|
||||
"<a href=\"&\" rel=\"nofollow\">&</a>".
|
||||
|
||||
get_room_info(RoomJID, Opts) ->
|
||||
Title =
|
||||
case lists:keysearch(title, 1, Opts) of
|
||||
|
Loading…
Reference in New Issue
Block a user