flyfire / android-notifier

Automatically exported from code.google.com/p/android-notifier
0 stars 0 forks source link

invalid character being passwd to external command (Windows) #248

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago

What steps will reproduce the problem?
1. Generate some event on the phone that has a description
2. Pass the argument to a external command.

What is the expected output? What do you see instead?
Expected:
Receive the full arguments passed to the program.
Receiving:
Partial arguments from the command line.

What version of the product are you using? On what operating system?
0.5.1 - Windows 32 bit

Please provide the log output if possible (from the alogcat app on android,
Show Log menu on the multiplatform client, or Console on native mac app):

2010-10-19 15:48:57,096 INFO [OperatingSystemProcessManagerImpl] - Output of 
command execution: "C:\.......\SpeakText.exe" 'XXXXXXXXXXXXXXXXXXX' 
'36530140497392074' 'BATTERY' '"84"' '"NOT charging, remaining charge: 84% "' 
'"Phone battery state"'

Usage:

C:\.....\SpeakText.exe {deviceId} {id} {type} {data} {description} {title}
Received 9 parameters, not 6.
Param[1]: 'XXXXXXXXXXXXXXXXXXX'
Param[2]: '36530140497392074'
Param[3]: 'BATTERY'
Param[4]: '84'
Param[5]: 'NOT
Param[6]: charging,
Param[7]: remaining
Param[8]: charge:
Param[9]: 84%

Note that there's a strange blank after the 84% on description.
Everything from the command line after that was cut off, and because of this, 
the closing quote was never parsed.
That happens on other types of messages as well:

2010-10-19 08:05:06,072 INFO [OperatingSystemProcessManagerImpl] - Output of 
command execution: "C:\....\SpeakText.exe" 2306194810258809440 
XXXXXXXXXXXXXXXXXXX SMS "4199" "SMS from 4199: Protocolo YYYYYYYYY finalizado. 
" "Phone received an SMS"

In this case, it's: "finalizado.(blank)"

Please provide any additional information below.
Seems like that do to this blank or invalid character, the rest of the command 
line get's cut off.
I'm using encryption for the client. I'll check if that's the culprit for this 
bug.

Original issue reported on code.google.com by djbr...@gmail.com on 19 Oct 2010 at 6:06

GoogleCodeExporter commented 9 years ago
The first obvious error is that the last 5 params above should have been a 
single param.

Original comment by rdamazio@gmail.com on 19 Oct 2010 at 6:25

GoogleCodeExporter commented 9 years ago
Note that exactly the 5th param is being passed as:
'{description}'

And that translates to:
'"NOT charging, remaining charge: 84% "'

But Windows is passing to my program only:
'"NOT charging, remaining charge: 84%

That's why it's not a single param. Everything after that last character is 
being cut off, and so the quotes have no effect. Initially I wasn't using any 
quotes since the notifier already adds the double quotes. I then tried escaping 
it with single quotes around it to debug it, but then I realized what was 
really going on.

I'm not familiar with the notifier source, but I bet that garbage character, 
that appears as blank on the logs, is the culprit of the problem.

I just tested without encryption on, and it is still not working.

Original comment by djbr...@gmail.com on 19 Oct 2010 at 6:34

GoogleCodeExporter commented 9 years ago
Yeah, there is a garbage character in the "description" field, I've noticed it 
while implementing USB communication and fixed it already, did not file an 
issue though. As you've said, the program already puts parameters in double 
quotes so you don't have to. A simple bat file with "echo %1 - %2 - %3 - %4 - 
%5 - %6" should print all parameters correctly.

Here is an exe file with the fix: 
http://dl.dropbox.com/u/1401233/248/android-notifier-desktop.exe

Thank you for posting a detailed report :)

Original comment by lehph...@gmail.com on 19 Oct 2010 at 7:15

GoogleCodeExporter commented 9 years ago
Issue 254 has been merged into this issue.

Original comment by lehph...@gmail.com on 22 Oct 2010 at 7:30

GoogleCodeExporter commented 9 years ago
Sorry for the delay, I didn't get updates from the issue on my email for some 
reason.

I just tried the exe you supplied, and it seems the garbage character is gone.
I'll try it on Linux later, but you can already mark this issue as closed I 
think.

Original comment by djbr...@gmail.com on 16 Nov 2010 at 2:11

GoogleCodeExporter commented 9 years ago
Great.

Original comment by lehph...@gmail.com on 16 Nov 2010 at 2:14