Backslash is stripped from incoming action messages

RESOLVED FIXED in 1.5

Status

Chat Core
General
RESOLVED FIXED
5 years ago
5 years ago

People

(Reporter: aleth, Assigned: nhnt11)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment, 2 obsolete attachments)

(Reporter)

Description

5 years ago
*** Original post on bio 1962 at 2013-05-18 09:13:00 UTC ***

STR: receive "/me says \t".
Possible regression from bug 955373 (bio 1935)?
(Assignee)

Comment 1

5 years ago
Created attachment 8354213 [details] [diff] [review]
Fix broken regular expression as well as bad tests.

*** Original post on bio 1962 as attmnt 2446 at 2013-05-22 20:48:00 UTC ***

This bug is a result of bad CTCP quoting (Bug 955405 (bio 1968)) as well as a bad regular expression (very similar to the cause of Bug 955405 (bio 1968)). This patch should take care of it.
Attachment #8354213 - Flags: review?(aleth)
Attachment #8354213 - Flags: feedback?(clokep)
(Assignee)

Comment 2

5 years ago
Comment on attachment 8354213 [details] [diff] [review]
Fix broken regular expression as well as bad tests.

*** Original change on bio 1962 attmnt 2446 at 2013-05-22 20:50:42 UTC was without comment, so any subsequent comment numbers will be shifted ***
Attachment #8354213 - Attachment description: This should fix it. → Fix broken regular expression as well as bad tests.
Comment on attachment 8354213 [details] [diff] [review]
Fix broken regular expression as well as bad tests.

*** Original change on bio 1962 attmnt 2446 at 2013-05-22 20:57:50 UTC ***

Initially this change looks ok. I want to test it before review though.
Attachment #8354213 - Flags: review?(clokep)
Attachment #8354213 - Flags: review?(aleth)
Attachment #8354213 - Flags: feedback?(clokep)
Attachment #8354213 - Flags: review?(aleth)
Comment on attachment 8354213 [details] [diff] [review]
Fix broken regular expression as well as bad tests.

*** Original change on bio 1962 attmnt 2446 at 2013-05-23 03:30:41 UTC ***

>diff --git a/chat/protocols/irc/ircCTCP.jsm b/chat/protocols/irc/ircCTCP.jsm
>   // High/CTCP level dequote: replace the quote char \134 followed by a or \134
>   // with \001 or \134, respectively. Any other character after \134 is replaced
>   // with itself.
>-  let dequotedCTCPMessage = message.ctcp.rawMessage.replace(/\x5C./g,
>-    function(aStr) aStr[1] == "a" ? "\x01" :
>-      aStr[1] == "\x5C" ? "\x5C\x5C" : aStr[1]);
>+  let dequotedCTCPMessage = message.ctcp.rawMessage.replace(/\\(.|$)/g,
>+    function(aStr) aStr[1] == "a" ? "\x01" : aStr[1] || "");
I find this somewhat confusing, as (according to operator precedence) this is equivalent to:
(aStr[1] == "a" ? "\x01" : aStr[1]) || "", I think you really want aStr[1] == "a" ? "\x01" : (aStr[1] || ""), but in this usage it's actually the same...so whatever.

> function run_test() {
>   let output = input.map(function(aStr) ircCTCP.CTCPMessage({}, aStr));
We should check if the lengths of the arrays are equal here.

All the test cases look good and I couldn't think of any other reasonable ones we should do.

You probably want to let aleth review this too before uploading a new patch.
Attachment #8354213 - Flags: review?(clokep) → review-
*** Original post on bio 1962 at 2013-05-23 03:31:52 UTC ***

Assigning.
Assignee: nobody → nhnt11
Status: NEW → ASSIGNED
Depends on: 955373
(Reporter)

Comment 6

5 years ago
Comment on attachment 8354213 [details] [diff] [review]
Fix broken regular expression as well as bad tests.

*** Original change on bio 1962 attmnt 2446 at 2013-05-24 13:39:50 UTC ***

>+  let dequotedCTCPMessage = message.ctcp.rawMessage.replace(/\\(.|$)/g,
>+    function(aStr) aStr[1] == "a" ? "\x01" : aStr[1] || "");
In addition to clokep's comments, this will throw a ReferenceError if $ is matched.
Attachment #8354213 - Flags: review?(aleth) → review-
(Assignee)

Comment 7

5 years ago
Created attachment 8354220 [details] [diff] [review]
Avoid ReferenceError

*** Original post on bio 1962 as attmnt 2453 at 2013-05-24 17:35:00 UTC was without comment, so any subsequent comment numbers will be shifted ***
Attachment #8354220 - Flags: review?(aleth)
(Assignee)

Updated

5 years ago
Attachment #8354220 - Flags: review?(clokep)
(Assignee)

Comment 8

5 years ago
Comment on attachment 8354213 [details] [diff] [review]
Fix broken regular expression as well as bad tests.

*** Original change on bio 1962 attmnt 2446 at 2013-05-24 17:35:15 UTC was without comment, so any subsequent comment numbers will be shifted ***
Attachment #8354213 - Attachment is obsolete: true
Comment on attachment 8354220 [details] [diff] [review]
Avoid ReferenceError

*** Original change on bio 1962 attmnt 2453 at 2013-05-24 17:42:56 UTC ***

Array lengths check wasn't added.
Attachment #8354220 - Flags: review?(clokep) → review-
(Assignee)

Comment 10

5 years ago
Created attachment 8354222 [details] [diff] [review]
Added array length check

*** Original post on bio 1962 as attmnt 2455 at 2013-05-24 23:31:00 UTC was without comment, so any subsequent comment numbers will be shifted ***
Attachment #8354222 - Flags: review?(aleth)
(Assignee)

Updated

5 years ago
Attachment #8354222 - Flags: review?(clokep)
(Assignee)

Comment 11

5 years ago
Comment on attachment 8354220 [details] [diff] [review]
Avoid ReferenceError

*** Original change on bio 1962 attmnt 2453 at 2013-05-24 23:31:41 UTC was without comment, so any subsequent comment numbers will be shifted ***
Attachment #8354220 - Attachment is obsolete: true
Attachment #8354220 - Flags: review?(aleth)
Comment on attachment 8354222 [details] [diff] [review]
Added array length check

*** Original change on bio 1962 attmnt 2455 at 2013-05-25 00:41:17 UTC ***

Excellent, thanks!
Attachment #8354222 - Flags: review?(clokep) → review+
(Reporter)

Comment 13

5 years ago
Comment on attachment 8354222 [details] [diff] [review]
Added array length check

*** Original change on bio 1962 attmnt 2455 at 2013-05-25 09:24:32 UTC ***

Thanks for diagnosing this tricky bug!
Attachment #8354222 - Flags: review?(aleth) → review+
(Reporter)

Updated

5 years ago
Whiteboard: [checkin-needed]
*** Original post on bio 1962 at 2013-05-31 00:36:53 UTC ***

Thanks for fixing this!

http://hg.instantbird.org/instantbird/rev/7b711ec1a864
Status: ASSIGNED → RESOLVED
Last Resolved: 5 years ago
Resolution: --- → FIXED
Whiteboard: [checkin-needed]
Target Milestone: --- → 1.5
You need to log in before you can comment on or make changes to this bug.