Re: Patch: gw/urltrans.c

"Nikos Balkanas" <[email protected]>
Newsgroups gmane.comp.mobile.kannel.devel
Message-ID <A79D9B4D553249CF829168599A7F49F2@drwho>
Case insensitivity is observed in the code. It just lacks in configuration. 
I changed patch to match documentation:

1) When given both keyword-regex and keyword, it will just prefer 
keyword-regex without complains (according to UG).
2) It will accept any case in configuration for both keyword and 
keyword-regex and do case incensitive matching.
3) Fixed a diagnostic that was pooping up evrywhere during matches.

Enjoy,
Nikos
----- Original Message ----- 
From: "Rene Kluwen" <[email protected]>
To: "'Alvaro Cornejo'" <[email protected]>; "'Nikos Balkanas'" 
<[email protected]>
Cc: <[email protected]>
Sent: Thursday, August 26, 2010 5:10 PM
Subject: RE: Patch: gw/urltrans.c


A lot of hand sets, nowadays automatically convert the first letter to
uppercase whilst typing an sms message.

So I think case-insensivity is not a bad thing?

== Rene

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf
Of Alvaro Cornejo
Sent: Thursday, 26 August, 2010 15:44
To: Nikos Balkanas
Cc: [email protected]
Subject: Re: Patch: gw/urltrans.c

It should then be noted in the user guide. Otherwise we will continue
receiving this questions over and over.

|---------------------------------------------------------------------------
--------------------------------------|
Envνe y Reciba Datos y mensajes de Texto (SMS) hacia y desde cualquier
celular y Nextel
en el Perϊ, Mιxico y en mas de 180 paises. Use aplicaciones 2 vias via
SMS y GPRS online
Visitenos en www.perusms.NET www.smsglobal.com.mx y
www.pravcom.com



2010/8/26 Nikos Balkanas <[email protected]>:
> I don't know if this is really necessary. Just using lower case in the
> keyword-regex pattern will work as well. Please disregard.
>
> BR,
> Nikos
> ----- Original Message ----- From: "Nikos Balkanas" <[email protected]>
> To: <[email protected]>
> Sent: Thursday, August 26, 2010 8:02 AM
> Subject: Patch: gw/urltrans.c
>
>
>> Hi,
>>
>> Currently keyword-regex is configured to only do exact case matches. This
>> is
>> in contrast to keyword matching, which is case incensitive. Additionaly,
>> input string input string is converted to lower case for matching. This
>> will
>> cause all keyword-regex patterns with capital letters to fail.
>>
>> This patch corrects that by inittializing keyword-regex to case
>> incensitive
>> matching.
>> Reported by Mike Cariotoglou
>>
>> BR,
>> Nikos
>>
>
>
>
urltrans.diff (application/octet-stream, 1.6 KB)
Index: gw/urltrans.c
===================================================================
RCS file: /home/cvs/gateway/gw/urltrans.c,v
retrieving revision 1.111
diff -a -u -b -r1.111 urltrans.c
--- gw/urltrans.c	14 Jan 2009 11:11:46 -0000	1.111
+++ gw/urltrans.c	26 Aug 2010 22:20:26 -0000
@@ -949,18 +949,14 @@
 	octstr_destroy(text);
 	octstr_destroy(exec);
 
-	tmp = cfg_get(grp, octstr_imm("keyword"));
-        keyword_regex = cfg_get(grp, octstr_imm("keyword-regex"));
-	if (tmp == NULL && keyword_regex == NULL) {
+    if ((keyword_regex = cfg_get(grp, octstr_imm("keyword-regex"))))
+        octstr_convert_range(keyword_regex, 0, octstr_len(keyword_regex), tolower);
+    else if ((tmp = cfg_get(grp, octstr_imm("keyword"))))
+        octstr_convert_range(tmp, 0, octstr_len(tmp), tolower);
+    else {
 	    error(0, "Group 'sms-service' must include either 'keyword' or 'keyword-regex'.");
 	    goto error;
 	}
-	if (tmp != NULL && keyword_regex != NULL) {
-	    error(0, "Group 'sms-service' may inlcude either 'keyword' or 'keyword-regex'.");
-	    octstr_destroy(tmp);
-	    octstr_destroy(keyword_regex);
-	    goto error;
-	}
 	
 	if (tmp != NULL && octstr_str_compare(tmp, "default") == 0) {
 	    /* default sms-service */
@@ -1353,11 +1349,12 @@
         if (gw_regex_match_pre(t->keyword_regex, msg) == 1) {
             debug("", 0, "match found: %s", octstr_get_cstr(t->name));
             gwlist_append(list, t);
-        } else {
-            debug("", 0, "no match found: %s", octstr_get_cstr(t->name));
         }
     }
     
+    if (!gwlist_len(list))
+       debug("", 0, "no match found: \"%s\"", octstr_get_cstr(msg));
+
     return list;
 }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.