faucamp / python-gsmmodem

Python module to control a GSM modem attached to the system: send/receive SMS messages, handle calls, etc
GNU Lesser General Public License v3.0
386 stars 303 forks source link

pdu.py generates PDU with >160 encoded characters leading to invalid SMS #71

Open babca opened 8 years ago

babca commented 8 years ago

If you try to send a message under 160 character long, containing some characters which need to be escaped, it is possible that an invalid >160 char single message is generated. It then appears as an empty incoming message on my phone.

12345-010,12345-020,12345-030,12345-040,12345-050,12345-060,12345-070,12345-080,12345-090,12345-100,12345-110,12345-120,12345-130,12345-140,12345-150,[[[[[[[[

This string is 158 char long. It contains 8 brackets which need an escape character, so the real length of the message is 166 septets. It should be split into two SMS, but it isn't.

How to quickly reproduce:

  1. open examples/sms_handler_demo.py
  2. replace sms.reply.... (line 23) with a static string sms.reply('12345-010,12345-020,12345-030,12345-040,12345-050,12345-060,12345-070,12345-080,12345-090,12345-100,12345-110,12345-120,12345-130,12345-140,12345-150,[[[[[[[[')
  3. save, start, send sms to modem and wait for the response.
  4. my phone receives an empty message
  5. copy generated PDU message here: http://rednaxela.net/pdu.php and check the contents by decoding it. It shows something like this: 123456789,123456789,123456789,123456789,123456789,123456789,123456789,123456789,123456789,12345-100,12345-110,12345-120,12345-130,12345-140,12345-150,€<€<€<€<€<€<€<€< Length:166