Bug 57715 - Problem with message highlighting and a '|' in nickname
Summary: Problem with message highlighting and a '|' in nickname
Status: RESOLVED FIXED
Alias: None
Product: ksirc
Classification: Miscellaneous
Component: general (show other bugs)
Version: unspecified
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: Andrew Stanley-Jones
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-04-25 20:19 UTC by Steffen Weber
Modified: 2003-04-26 07:26 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Steffen Weber 2003-04-25 20:19:39 UTC
Version:            (using KDE Devel)
Installed from:    Compiled sources
Compiler:          GCC 3.2.2 
OS:          Linux

I've got a '|' in my nickname and messages are highlighted if either the part of my nick left to the '|' _or_ the part right to the '|' are mentioned by someone, although a message should only be highlighted if my complete nickname is in the message. Might this be because a | means "or" in regular expressions?
Comment 1 Steffen Weber 2003-04-25 20:21:56 UTC
Correction: A message is only highlighted if the part left to the '|' is in it. The part on the right 
side does not seem to have any effect. 
Comment 2 Andrew Stanley-Jones 2003-04-25 20:54:46 UTC
This happens with for nicks with \ in them.  \s \S \w \W result in interesting 
messages.  I was looking at this this morning and should have it fixed soon in 
HEAD.

is . legal in nicks?
Comment 3 Steffen Weber 2003-04-25 22:04:41 UTC
When I try to do "/nick MyNick." the dot is cut, but I don't know whether teh server or KSirc 
does this so, so maybe this doesn't answer your question. While looking through the IRC RFC I 
was not able to find any information regarding this issue. :-( 
Comment 4 Andrew Stanley-Jones 2003-04-26 07:26:49 UTC
Subject: kdenetwork/ksirc

CVS commit by asj: 

Cleans up nick regex so we escape regex characters that can be used in nicks.
Like say \ | etc.

CCMAIL: 57715-done@bugs.kde.org


  M +11 -0     baserules.cpp   1.21


--- kdenetwork/ksirc/baserules.cpp  #1.20:1.21
@@ -81,4 +81,15 @@ filterRuleList *KSMBaseRules::defaultRul
             nick.truncate( 83 );
         }
+        /*
+         * Since the nick is used in the regex we must
+         * escape all regex words
+         */
+        nick.replace("\\", "\\\\");
+        nick.replace("|", "\\|");
+        nick.replace("^", "\\^");
+        nick.replace("{", "\\{");
+        nick.replace("}", "\\}");
+        nick.replace("[", "\\[");
+        nick.replace("]", "\\]");
         sprintf(match_us,
                 "(?i)<\\S+>.*\\s%s(,.*|\02:.*|:.*|\\s.*|$)", nick.latin1());


Comment 5 Andrew Stanley-Jones 2003-04-26 07:44:31 UTC
Subject: kdenetwork/ksirc

CVS commit by asj: 

frerich suggested a much better approach

CCMAIL: 57715@bugs.kde.org


  M +4 -7      baserules.cpp   1.22


--- kdenetwork/ksirc/baserules.cpp  #1.21:1.22
@@ -4,4 +4,6 @@
 #include "ksircprocess.h"
 
+#include <qregexp.h>
+
 #include <stdio.h>
 
@@ -85,11 +87,6 @@ filterRuleList *KSMBaseRules::defaultRul
          * escape all regex words
          */
-        nick.replace("\\", "\\\\");
-        nick.replace("|", "\\|");
-        nick.replace("^", "\\^");
-        nick.replace("{", "\\{");
-        nick.replace("}", "\\}");
-        nick.replace("[", "\\[");
-        nick.replace("]", "\\]");
+        nick = QRegExp::escape(nick);
+
         sprintf(match_us,
                 "(?i)<\\S+>.*\\s%s(,.*|\02:.*|:.*|\\s.*|$)", nick.latin1());