webpro2 / javapns

Automatically exported from code.google.com/p/javapns
0 stars 0 forks source link

manager.sendNotification("1","...") index out of range exception #51

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. pass a device token of uneven length to manager.sendNotification()

What is the expected output? What do you see instead?

to throw and invalid argument exception or invalid device token exception (or 
perhaps UnknownDeviceToken exception), instead it throws and index out of range 
exception which doesn't really give a clue as to what is wrong.

What version of the product are you using? On what operating system?

Revision 152
OSX

Please provide any additional information below.

java.lang.StringIndexOutOfBoundsException: String index out of range: 2
    at java.lang.String.substring(String.java:1934)
    at javapns.back.PushNotificationManager.getMessage(PushNotificationManager.java:251)
    at javapns.back.PushNotificationManager.sendNotification(PushNotificationManager.java:131)
    at com.redskyit.apns.processors.NotificatonProcessor.send(NotificatonProcessor.java:223)
    at com.redskyit.apns.processors.NotificatonProcessor.process_NOTIFY(NotificatonProcessor.java:184)
    at com.redskyit.apns.processors.NotificatonProcessor.process(NotificatonProcessor.java:203)
    at com.redskyit.server.Server.process(Server.java:58)
    at com.redskyit.server.Server.run(Server.java:38)
    at com.redskyit.apns.apns.main(apns.java:41)

Original issue reported on code.google.com by Austin.France on 24 May 2011 at 3:14

GoogleCodeExporter commented 9 years ago
Just to verify... you are asking that the Device Token length be checked when 
the Token is passed to the Device object?

Added to 1.6.8

Original comment by idb...@pugetworks.com on 24 May 2011 at 9:32

GoogleCodeExporter commented 9 years ago
Yes and Thanks

Original comment by Austin.France on 24 May 2011 at 11:13

GoogleCodeExporter commented 9 years ago
Even though the javapns.data.Device (1.x) and 
javapns.devices.implementations.basic.BasicDevice (2.0) constructors do 
validate the token format, it is possible to pass a custom implementation of 
Device which would bypass the constructor-level validation.

I have improved the token validation in the 2.0 branch so that 
PushNotificationManager always validates the token in sendNotification(...).  
The fix will be in my next commit.

Original comment by sype...@gmail.com on 7 Sep 2011 at 3:59