diff options
author | Badlop <badlop@process-one.net> | 2013-01-31 20:25:03 +0400 |
---|---|---|
committer | Badlop <badlop@process-one.net> | 2013-01-31 20:25:03 +0400 |
commit | 15073aafa58871b8d5e25652d492fb3a76900d5b (patch) | |
tree | b8f4698319511c7e0c8ce3ad3a2afd4428d7809d | |
parent | 0ae400533c02cdaffd2f6e24af2067a7d1b673da (diff) |
Fix angle brackets handle in MUC plaintext log (EJAB-1610)
-rw-r--r-- | src/mod_muc/mod_muc_log.erl | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/mod_muc/mod_muc_log.erl b/src/mod_muc/mod_muc_log.erl index 5db2b5f19..c6eb783e4 100644 --- a/src/mod_muc/mod_muc_log.erl +++ b/src/mod_muc/mod_muc_log.erl @@ -52,6 +52,8 @@ -define(PROCNAME, ejabberd_mod_muc_log). -record(room, {jid, title, subject, subject_author, config}). +-define(PLAINTEXT_IN, "ZZIZZ"). +-define(PLAINTEXT_OUT, "ZZOZZ"). -record(logstate, {host, out_dir, @@ -311,6 +313,11 @@ write_last_lines(F, Images_dir, _FileFormat) -> fw(F, " <a href=\"http://jigsaw.w3.org/css-validator/\"><img style=\"border:0;width:88px;height:31px\" src=\"~s/vcss.png\" alt=\"Valid CSS!\"/></a>", [Images_dir]), fw(F, "</span></div></body></html>"). +htmlize_nick(Nick1, html) -> + htmlize("<"++Nick1++">", html); +htmlize_nick(Nick1, plaintext) -> + htmlize(?PLAINTEXT_IN++Nick1++?PLAINTEXT_OUT, plaintext). + add_message_to_log(Nick1, Message, RoomJID, Opts, State) -> #logstate{out_dir = OutDir, dir_type = DirType, @@ -323,7 +330,7 @@ add_message_to_log(Nick1, Message, RoomJID, Opts, State) -> top_link = TopLink} = State, Room = get_room_info(RoomJID, Opts), Nick = htmlize(Nick1, FileFormat), - Nick2 = htmlize("<"++Nick1++">", FileFormat), + Nick2 = htmlize_nick(Nick1, FileFormat), Now = now(), TimeStamp = case Timezone of local -> calendar:now_to_local_time(Now); @@ -662,7 +669,9 @@ fw(F, S, O, FileFormat) -> html -> S1; plaintext -> - ejabberd_regexp:greplace(S1, "<[^>]*>", "") + S1x = ejabberd_regexp:greplace(S1, "<[^<^>]*>", ""), + S1y = ejabberd_regexp:greplace(S1x, ?PLAINTEXT_IN, "<"), + ejabberd_regexp:greplace(S1y, ?PLAINTEXT_OUT, ">") end, io:format(F, S2, []). @@ -774,7 +783,8 @@ htmlize(S1, FileFormat) -> %% The NoFollow parameter tell if the spam prevention should be applied to the link found %% true means 'apply nofollow on links'. htmlize(S1, _NoFollow, plaintext) -> - S1; + S1x = ejabberd_regexp:replace(S1, "<", ?PLAINTEXT_IN), + ejabberd_regexp:replace(S1x, ">", ?PLAINTEXT_OUT); htmlize(S1, NoFollow, _FileFormat) -> S2_list = string:tokens(S1, "\n"), lists:foldl( |