After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 691085 - Backslash escapes applied in the chat log
Backslash escapes applied in the chat log
Status: RESOLVED FIXED
Product: empathy
Classification: Core
Component: General
3.4.x
Other Linux
: Normal normal
: ---
Assigned To: empathy-maint
empathy-maint
Depends on: 89548
Blocks:
 
 
Reported: 2013-01-03 17:49 UTC by Alyssa Haroldsen
Modified: 2013-06-26 08:47 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Screenshot of the issue (242.39 KB, image/png)
2013-01-03 17:54 UTC, Alyssa Haroldsen
  Details
log-window: escape the body of the message (1.84 KB, patch)
2013-01-04 15:09 UTC, Guillaume Desmottes
committed Details | Review
Fix escaping of text in empathy log window (1.99 KB, patch)
2013-06-08 16:21 UTC, Allison Karlitskaya (desrt)
committed Details | Review

Description Alyssa Haroldsen 2013-01-03 17:49:27 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
Comment 1 Alyssa Haroldsen 2013-01-03 17:54:24 UTC
Created attachment 232656 [details]
Screenshot of the issue
Comment 2 Guillaume Desmottes 2013-01-04 15:09:01 UTC
Created attachment 232735 [details] [review]
log-window: escape the body of the message
Comment 3 Xavier Claessens 2013-01-07 12:20:00 UTC
+1
Comment 4 Guillaume Desmottes 2013-01-07 13:05:14 UTC
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
Comment 5 Serge Gavrilov 2013-01-29 08:11:12 UTC
The patch applied causes bug #692746
Comment 6 Guillaume Desmottes 2013-05-24 12:48:39 UTC
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.
Comment 8 Allison Karlitskaya (desrt) 2013-06-08 15:23:21 UTC
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?
Comment 9 Allison Karlitskaya (desrt) 2013-06-08 16:21:31 UTC
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.
Comment 10 Igor Gnatenko 2013-06-08 17:02:14 UTC
Review of attachment 246313 [details] [review]:

Works OK in 3-8 and 3-6 branch
Comment 11 Guillaume Desmottes 2013-06-24 08:11:15 UTC
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).
Comment 12 Guillaume Desmottes 2013-06-26 08:47:07 UTC
Attachment 246313 [details] pushed as 6bace22 - Fix escaping of text in empathy log window