[Tkabber-dev] r2114 - in trunk/tkabber-plugins: . otr otr/tclotr otr/trans

tkabber-svn at jabber.ru tkabber-svn at jabber.ru
Mon Jan 27 21:32:17 MSK 2014


Author: sergei
Date: 2014-01-27 21:32:17 +0400 (Mon, 27 Jan 2014)
New Revision: 2114

Modified:
   trunk/tkabber-plugins/ChangeLog
   trunk/tkabber-plugins/otr/otr.tcl
   trunk/tkabber-plugins/otr/tclotr/message.tcl
   trunk/tkabber-plugins/otr/trans/ru.msg
Log:
	* otr/tclotr/message.tcl: Treat human readable message part as HTML
	  (strip tags for incoming messages, escape HTML entities for
	  outgoing ones).

	* otr/otr.tcl, otr/trans/ru.msg: Removed repeated link.


Modified: trunk/tkabber-plugins/ChangeLog
===================================================================
--- trunk/tkabber-plugins/ChangeLog	2014-01-27 12:05:32 UTC (rev 2113)
+++ trunk/tkabber-plugins/ChangeLog	2014-01-27 17:32:17 UTC (rev 2114)
@@ -17,6 +17,12 @@
 
 	* otr/README: Fixed info on how to use private keys.
 
+	* otr/tclotr/message.tcl: Treat human readable message part as HTML
+	  (strip tags for incoming messages, escape HTML entities for
+	  outgoing ones).
+
+	* otr/otr.tcl, otr/trans/ru.msg: Removed repeated link.
+
 2014-01-26  Sergei Golovan <sgolovan at nes.ru>
 
 	* otr/tclotr/otr.tcl: Fixed refreshing private connection if the

Modified: trunk/tkabber-plugins/otr/otr.tcl
===================================================================
--- trunk/tkabber-plugins/otr/otr.tcl	2014-01-27 12:05:32 UTC (rev 2113)
+++ trunk/tkabber-plugins/otr/otr.tcl	2014-01-27 17:32:17 UTC (rev 2114)
@@ -451,10 +451,10 @@
 
     ::otr::requestConversation $ctx($xlib,$jid) \
 	  \n[format [::trans::trans $lang \
-		    "%s has requested an Off-the-Record private conversation\
-		    <http://otr.cypherpunks.ca/>. However, you do not have a\
-		    plugin to support that.\nSee http://otr.cypherpunks.ca/\
-		    for more information."] [my_jid $xlib $jid]]]
+		    "%s has requested an Off-the-Record private conversation.\
+		    However, you do not have a plugin to support that.\nSee\
+		    http://otr.cypherpunks.ca/ for more information."] \
+		    [my_jid $xlib $jid]]]
 }
 
 proc otr::finish_session {xlib jid type} {

Modified: trunk/tkabber-plugins/otr/tclotr/message.tcl
===================================================================
--- trunk/tkabber-plugins/otr/tclotr/message.tcl	2014-01-27 12:05:32 UTC (rev 2113)
+++ trunk/tkabber-plugins/otr/tclotr/message.tcl	2014-01-27 17:32:17 UTC (rev 2114)
@@ -461,7 +461,7 @@
 #       None.
 
 proc ::otr::message::createDataMessagePlaintext {humanreadable tlvlist} {
-    set res [encoding convertto utf-8 $humanreadable]
+    set res [encoding convertto utf-8 [escapeHTML $humanreadable]]
     if {[string first \x00 $res] >= 0} {
         return -code error "Zero byte in the human readable message part"
     }
@@ -476,6 +476,23 @@
     set res
 }
 
+# ::otr::message::escapeHTML --
+#
+#       Return a text message with escaped HTML entities.
+#
+# Arguments:
+#       message         Text message.
+#
+# Result:
+#       Text with HTML entities.
+#
+# Side effects:
+#       None.
+
+proc ::otr::message::escapeHTML {message} {
+    string map {& & < < > > \" " \n <br>} $message
+}
+
 # ::otr::message::parseDataMessagePlaintext --
 #
 #       Parse an OTR data message plaintest part.
@@ -501,7 +518,29 @@
         lassign [::otr::data::decodeTLV $data] type value data
         lappend tlvlist $type $value
     }
-    list [encoding convertfrom utf-8 $hrutf8] $tlvlist
+    list [stripHTML [encoding convertfrom utf-8 $hrutf8]] $tlvlist
 }
 
+# ::otr::message::stripHTML --
+#
+#       Remove HTML tags from a message.
+#
+# Arguments:
+#       message         Message to remove HTML tags from.
+#
+# Result:
+#       The plain text message.
+#
+# Side effects:
+#       None.
+#
+# Bugs:
+#       The tag stripper is very basic. Should really use htmlparse or so.
+
+proc ::otr::message::stripHTML {message} {
+    set message [regsub -all {<br[^>]*>} $message "\n"]
+    set message [regsub -all {<[^>]*>} $message ""]
+    string map {< < > > " \" ' ' & &} $message
+}
+
 # vim:ts=8:sw=4:sts=4:et

Modified: trunk/tkabber-plugins/otr/trans/ru.msg
===================================================================
--- trunk/tkabber-plugins/otr/trans/ru.msg	2014-01-27 12:05:32 UTC (rev 2113)
+++ trunk/tkabber-plugins/otr/trans/ru.msg	2014-01-27 17:32:17 UTC (rev 2114)
@@ -1,10 +1,9 @@
 # $Id$
 
-::trans::trset ru "%s has requested an Off-the-Record private conversation\
-	<http://otr.cypherpunks.ca/>. However, you do not have a plugin to\
-	support that.\nSee http://otr.cypherpunks.ca/ for more\
-	information." "%s хочет начать с вами непрослушиваемый разговор по\
-	протоколу OTR <http://otr.cypherpunks.ca/>. Однако, у вас нет\
+::trans::trset ru "%s has requested an Off-the-Record private conversation.\
+	However, you do not have a plugin to support that.\nSee\
+	http://otr.cypherpunks.ca/ for more information." "%s хочет начать\
+	с вами непрослушиваемый разговор по протоколу OTR. Однако, у вас нет\
 	расширения, которе поддерживает этот протокол. Подробности по\
 	ссылке http://otr.cypherpunks.ca/"
 ::trans::trset ru "Encrypted message can't be deciphered" "Зашифрованное\



More information about the Tkabber-dev mailing list