GNOME Bugzilla – Bug 691085
Backslash escapes applied in the chat log
Last modified: 2013-06-26 08:47:13 UTC
Originally reported at: https://bugs.launchpad.net/bugs/1068242 When viewing the chat log, and someone sends me text containing what would be considered a backslash escape in most programming languages, the escapes will be applied. For example, the UNC Path "\\servername\c$\source" is displayed as "\sw01-v2-1c$Source" in the chat log. As you might imagine, this can get annoying - especially when sending data like Windows paths, which are usually chock-full of backslashes. I tested the standard escapes like \n, \r, and \t If I send someone the text "1\\2\n3\r4\r\n5\t6\\?", this is shown in the log: 1\2 3 4 5 6\? Strangely, in the faded "last chat" that's shown when you talk to someone whom you have talked to before, the text is intact - no escapes are applied. Please sanitize these strings before they are displayed in the log ;-) The important info in a nutshell: Ubuntu Version: Precise Pangolin 12.04 64-bit Empathy Version: 3.4.2.3-0ubuntu1 What I expected to happen: My chat's backslashes to be preserved when viewing in the log What happened instead: My chat's text is having backslash escapes applied Just to be sure, I tested this bug in multiple protocols. It is present in the Google Talk, Facebook, and SIPE protocol chat history. I assume it is a bug of the log viewer itself. To be honest, I'm surprised this has gone unnoticed for so long. Thank you, - Kupiakos
Created attachment 232656 [details] Screenshot of the issue
Created attachment 232735 [details] [review] log-window: escape the body of the message
+1
I merged to 3.6 and master; I may do a 3.6 stable release at some point. Attachment 232735 [details] pushed as 1e7449f - log-window: escape the body of the message
The patch applied causes bug #692746
Re-opening this bug as explained in https://git.gnome.org/browse/empathy/commit/?h=gnome-3-8 We'll fix it properly once bug #89548 is fixed.
Commit: https://git.gnome.org/browse/empathy/commit/?h=gnome-3-8&id=7e2db943e0c9a6f5764504460e64ffec9bb87d67
The real problem is this line: script = g_strdup_printf ("javascript:%s([%s], '%s', '%s', '%s');", method, g_strdelimit (str, ":", ','), text, icon != NULL ? icon : "", date); and that's where the escaping should take place. So the question is of creating an escaping function that is compatible with the needs of Javascript. What are those? Could also figure out a better/more-direct way of modifying the data -- perhaps going via DOM instead?
Created attachment 246313 [details] [review] Fix escaping of text in empathy log window We insert text into the log window by using a javascript expression, with the text to insert quoted with single quotes. Ensure that we apply the correct escaping so that backslashes and quote characters are taken literally.
Review of attachment 246313 [details] [review]: Works OK in 3-8 and 3-6 branch
Review of attachment 246313 [details] [review]: Thanks for the patch Ryan. It looks good to me, please merge to the 3.8 branch (and eventually merge gnome-3-8 to master or I'll do it myself).
Attachment 246313 [details] pushed as 6bace22 - Fix escaping of text in empathy log window