[Windows Mobile Apps and Games] kuzco1:
Hi,

ok, I have checked rtmain.cs according to the password problem and I have fixed it (hopefully).

As far as I understood the password policy only 0-9 and a-z are allowed. A-Z will converted automatically to lower characters a-z. Is that correct ?

The problem:

The full SMS I received is (SMS via eMail - gmx.de):

01.12.08 09:27:29 - mi_MessageReceived. Text2-FullSMS: rt#ego##1234/

--

sensationsangebot nur bis 30.11: gmx freedsl - telefonanschluss + dsl

für nur 16,37 euro/mtl.!* http://dsl.gmx.de/?ac=om.ad.pd003k11308t4569a

The code

password = Utils.RemoveInvallidChars (words[3].Trim().ToLower());

makes sure that the password will be

1234sensationsangebotnurbis3011gmxfreedsltelefonanschlussdslfrnur1637euromtlhttpdslgmxdeacomadpd003k11308t4569a

BUT, the password is only 1234.

Means Utils.RemoveInvallidChars deletes the invalid characters, but it does not makes sure that the password length is 4 in this case. The first invalid character was / at position 5.

Solution:

words[3] has to checked if words[3] includes an invalid character. If not, than password will be ok. Nothing to do.

If yes, it has to checked for the first invalid character. Passwordlength is than the position of first invalid character -1.

I have tested it with:

- SMS via EMail (GMX.NET)

- SMS via EMail (company mail-account)

- SMS vio Phone

All three were o.k.

The my solution works, probably there exists a better way.

I have marked all changes with //*

-----------------------------------------

OLD:

string text2 = "";

char letter;

// Make a clean string, without control characters

for (int i = 0; i < text.Length; i++)

{

letter = System.Convert.ToChar(text.Substring(i, 1));

if (((int)letter >= 32 || (int)letter <= 122) && (int)letter != 34)

{

text2 += text.Substring(i, 1);

}

}

text2 = text2.Trim();

char[] delimiterChars = { '#' };

string[] words = text2.Split(delimiterChars);

// Getting command

String command = "";

String password = "";

Commands.TelSMS = "";

if (words.Length > 1)

{

command = words[1].Trim();

if (words.Length > 2)

{

Commands.TelSMS = words[2].Trim();

if (words.Length > 3)

{

password = Utils.RemoveInvallidChars (words[3].Trim().ToLower());

}

}

}

-----------------------------------------

NEW:

//* string text2 = "";

//* char letter;

// Make a clean string, without control characters

//* for (int i = 0; i < text.Length; i++)

//* {

//* letter = System.Convert.ToChar(text.Substring(i, 1));

//* if (((int)letter >= 32 || (int)letter <= 122) && (int)letter != 34)

//* {

//* text2 += text.Substring(i, 1);

//* }

//* }

//* text2 = text2.Trim();

char[] delimiterChars = { '#' };

//* next line deleted - text2 not longer necessary

//* string[] words = text2.Split(delimiterChars);

//* line added - texct is the received message

string[] words = text.Split(delimiterChars);

// Getting command

String command = "";

String password = "";

Commands.TelSMS = "";

//* line added - length of password

int lenpassword = 0;

if (words.Length > 1)

{

command = words[1].Trim();

if (words.Length > 2)

{

Commands.TelSMS = words[2].Trim();

if (words.Length > 3)

{

//* password = Utils.RemoveInvallidChars (words[3].Trim().ToLower());

//* START - special check for SMS over eMail/WEB

//* checking for first invalid character

password = (words[3].Trim().ToLower());

foreach (char c in password)

// 0 - 48; 9 - 57; a - 97; z - 122

if (((int)c > 47 && (int)c < 58) || ((int)c > 96 && (int)c < 123))

{

lenpassword = lenpassword + 1;

}

else

{

lenpassword = lenpassword;

break;

}

password = words[3].Substring(0, lenpassword);

//* END - special check for SMS over eMail/WEB

}

}

}

//* START - Special Test for SMS via email

#if debugmode

Debug.AddLog("mi_MessageReceived. Command: SPECIAL TEST FOR SMS OVER Mail/WEB", true);

Debug.AddLog("mi_MessageReceived. Command: " + command + "_END", true);

Debug.AddLog("mi_MessageReceived. TelSMS: " + Commands.TelSMS + "_END", true);

Debug.AddLog("mi_MessageReceived. OldPassword: " + words[3].Trim().ToLower() + "_END", true);

Debug.AddLog("mi_MessageReceived. NewPassword: " + password + "_END", true);

Debug.AddLog("mi_MessageReceived. Length: " + lenpassword + "_END", true);

foreach (char c in password)

Debug.AddLog("mi_MessageReceived. ASCII: " + (int)c + "_END", true);

Debug.AddLog("mi_MessageReceived. Command: SPECIAL TEST FOR SMS OVER Mail/WEB", true);

#endif

//* END - Special Test for SMS via email

-----------------------------------------

You have to delete of course the entries for the debug-log -if you want.

Attached the new rtmain.cs.

Regards

kuzco